@sveda-ai/vue 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (490) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +9 -0
  3. package/dist/appearance.d.ts +52 -0
  4. package/dist/appearance.d.ts.map +1 -0
  5. package/dist/components/chat/AnimatedStreamBlock.vue.d.ts +16 -0
  6. package/dist/components/chat/AnimatedStreamBlock.vue.d.ts.map +1 -0
  7. package/dist/components/chat/ChatHistoryDropdown.vue.d.ts +17 -0
  8. package/dist/components/chat/ChatHistoryDropdown.vue.d.ts.map +1 -0
  9. package/dist/components/chat/ChatInput.vue.d.ts +30 -0
  10. package/dist/components/chat/ChatInput.vue.d.ts.map +1 -0
  11. package/dist/components/chat/ChatMessageActivityBlock.vue.d.ts +13 -0
  12. package/dist/components/chat/ChatMessageActivityBlock.vue.d.ts.map +1 -0
  13. package/dist/components/chat/ChatMessageItem.vue.d.ts +15 -0
  14. package/dist/components/chat/ChatMessageItem.vue.d.ts.map +1 -0
  15. package/dist/components/chat/ChatMessageList.vue.d.ts +31 -0
  16. package/dist/components/chat/ChatMessageList.vue.d.ts.map +1 -0
  17. package/dist/components/chat/ChatPendingIndicator.vue.d.ts +12 -0
  18. package/dist/components/chat/ChatPendingIndicator.vue.d.ts.map +1 -0
  19. package/dist/components/chat/ReasoningStream.vue.d.ts +11 -0
  20. package/dist/components/chat/ReasoningStream.vue.d.ts.map +1 -0
  21. package/dist/components/chat/index.d.ts +9 -0
  22. package/dist/components/chat/index.d.ts.map +1 -0
  23. package/dist/components/shell/SvedaAgentCompletedNotice.vue.d.ts +9 -0
  24. package/dist/components/shell/SvedaAgentCompletedNotice.vue.d.ts.map +1 -0
  25. package/dist/components/shell/SvedaAgentTasksPanel.vue.d.ts +12 -0
  26. package/dist/components/shell/SvedaAgentTasksPanel.vue.d.ts.map +1 -0
  27. package/dist/components/shell/SvedaChat.vue.d.ts +22 -0
  28. package/dist/components/shell/SvedaChat.vue.d.ts.map +1 -0
  29. package/dist/components/shell/SvedaContextUsageBar.vue.d.ts +10 -0
  30. package/dist/components/shell/SvedaContextUsageBar.vue.d.ts.map +1 -0
  31. package/dist/components/shell/SvedaHistorySheet.vue.d.ts +15 -0
  32. package/dist/components/shell/SvedaHistorySheet.vue.d.ts.map +1 -0
  33. package/dist/components/shell/SvedaHistorySidebar.vue.d.ts +15 -0
  34. package/dist/components/shell/SvedaHistorySidebar.vue.d.ts.map +1 -0
  35. package/dist/components/shell/SvedaInputSection.vue.d.ts +25 -0
  36. package/dist/components/shell/SvedaInputSection.vue.d.ts.map +1 -0
  37. package/dist/components/shell/SvedaLandingView.vue.d.ts +40 -0
  38. package/dist/components/shell/SvedaLandingView.vue.d.ts.map +1 -0
  39. package/dist/components/shell/SvedaMaxStepsNotice.vue.d.ts +13 -0
  40. package/dist/components/shell/SvedaMaxStepsNotice.vue.d.ts.map +1 -0
  41. package/dist/components/shell/SvedaMinimizedTrigger.vue.d.ts +15 -0
  42. package/dist/components/shell/SvedaMinimizedTrigger.vue.d.ts.map +1 -0
  43. package/dist/components/shell/SvedaModelControls.vue.d.ts +12 -0
  44. package/dist/components/shell/SvedaModelControls.vue.d.ts.map +1 -0
  45. package/dist/components/shell/SvedaModelSelect.vue.d.ts +10 -0
  46. package/dist/components/shell/SvedaModelSelect.vue.d.ts.map +1 -0
  47. package/dist/components/shell/SvedaQuickPrompts.vue.d.ts +13 -0
  48. package/dist/components/shell/SvedaQuickPrompts.vue.d.ts.map +1 -0
  49. package/dist/components/shell/SvedaResizeHandles.vue.d.ts +11 -0
  50. package/dist/components/shell/SvedaResizeHandles.vue.d.ts.map +1 -0
  51. package/dist/components/shell/SvedaTabs.vue.d.ts +17 -0
  52. package/dist/components/shell/SvedaTabs.vue.d.ts.map +1 -0
  53. package/dist/components/shell/SvedaToolbar.vue.d.ts +33 -0
  54. package/dist/components/shell/SvedaToolbar.vue.d.ts.map +1 -0
  55. package/dist/composables/useSvedaAgentTasks.d.ts +57 -0
  56. package/dist/composables/useSvedaAgentTasks.d.ts.map +1 -0
  57. package/dist/composables/useSvedaBootstrap.d.ts +18 -0
  58. package/dist/composables/useSvedaBootstrap.d.ts.map +1 -0
  59. package/dist/composables/useSvedaChat.d.ts +264 -0
  60. package/dist/composables/useSvedaChat.d.ts.map +1 -0
  61. package/dist/composables/useSvedaChatLayout.d.ts +39 -0
  62. package/dist/composables/useSvedaChatLayout.d.ts.map +1 -0
  63. package/dist/composables/useSvedaChatPage.d.ts +309 -0
  64. package/dist/composables/useSvedaChatPage.d.ts.map +1 -0
  65. package/dist/composables/useSvedaContextWindow.d.ts +10 -0
  66. package/dist/composables/useSvedaContextWindow.d.ts.map +1 -0
  67. package/dist/composables/useSvedaDocuments.d.ts +20 -0
  68. package/dist/composables/useSvedaDocuments.d.ts.map +1 -0
  69. package/dist/composables/useSvedaMaxStepsContinue.d.ts +12 -0
  70. package/dist/composables/useSvedaMaxStepsContinue.d.ts.map +1 -0
  71. package/dist/composables/useSvedaMessaging.d.ts +55 -0
  72. package/dist/composables/useSvedaMessaging.d.ts.map +1 -0
  73. package/dist/composables/useSvedaModel.d.ts +16 -0
  74. package/dist/composables/useSvedaModel.d.ts.map +1 -0
  75. package/dist/composables/useSvedaPrompts.d.ts +18 -0
  76. package/dist/composables/useSvedaPrompts.d.ts.map +1 -0
  77. package/dist/composables/useSvedaReadable.d.ts +3 -0
  78. package/dist/composables/useSvedaReadable.d.ts.map +1 -0
  79. package/dist/composables/useSvedaScroll.d.ts +19 -0
  80. package/dist/composables/useSvedaScroll.d.ts.map +1 -0
  81. package/dist/composables/useSvedaShell.d.ts +29 -0
  82. package/dist/composables/useSvedaShell.d.ts.map +1 -0
  83. package/dist/composables/useSvedaStreaming.d.ts +46 -0
  84. package/dist/composables/useSvedaStreaming.d.ts.map +1 -0
  85. package/dist/composables/useSvedaTool.d.ts +4 -0
  86. package/dist/composables/useSvedaTool.d.ts.map +1 -0
  87. package/dist/i18n/index.d.ts +18 -0
  88. package/dist/i18n/index.d.ts.map +1 -0
  89. package/dist/i18n/locales/en.d.ts +4 -0
  90. package/dist/i18n/locales/en.d.ts.map +1 -0
  91. package/dist/i18n/locales/ru.d.ts +4 -0
  92. package/dist/i18n/locales/ru.d.ts.map +1 -0
  93. package/dist/index.d.ts +64 -0
  94. package/dist/index.d.ts.map +1 -0
  95. package/dist/index.js +6612 -0
  96. package/dist/launcherIcons.d.ts +5 -0
  97. package/dist/launcherIcons.d.ts.map +1 -0
  98. package/dist/lib/assistantMessage.d.ts +89 -0
  99. package/dist/lib/assistantMessage.d.ts.map +1 -0
  100. package/dist/lib/chatHistoryMerge.d.ts +20 -0
  101. package/dist/lib/chatHistoryMerge.d.ts.map +1 -0
  102. package/dist/lib/chatI18nKeys.d.ts +2 -0
  103. package/dist/lib/chatI18nKeys.d.ts.map +1 -0
  104. package/dist/lib/chatMessageVisibility.d.ts +4 -0
  105. package/dist/lib/chatMessageVisibility.d.ts.map +1 -0
  106. package/dist/lib/chatTabs.d.ts +9 -0
  107. package/dist/lib/chatTabs.d.ts.map +1 -0
  108. package/dist/lib/chatTitle.d.ts +3 -0
  109. package/dist/lib/chatTitle.d.ts.map +1 -0
  110. package/dist/lib/chatUiStorage.d.ts +4 -0
  111. package/dist/lib/chatUiStorage.d.ts.map +1 -0
  112. package/dist/lib/finalizeMessages.d.ts +21 -0
  113. package/dist/lib/finalizeMessages.d.ts.map +1 -0
  114. package/dist/lib/markdown.d.ts +8 -0
  115. package/dist/lib/markdown.d.ts.map +1 -0
  116. package/dist/lib/modelLabels.d.ts +3 -0
  117. package/dist/lib/modelLabels.d.ts.map +1 -0
  118. package/dist/lib/pendingStatusRotation.d.ts +3 -0
  119. package/dist/lib/pendingStatusRotation.d.ts.map +1 -0
  120. package/dist/lib/useAnimatedText.d.ts +8 -0
  121. package/dist/lib/useAnimatedText.d.ts.map +1 -0
  122. package/dist/lib/userMessage.d.ts +17 -0
  123. package/dist/lib/userMessage.d.ts.map +1 -0
  124. package/dist/lib/utils.d.ts +3 -0
  125. package/dist/lib/utils.d.ts.map +1 -0
  126. package/dist/plugin.d.ts +64 -0
  127. package/dist/plugin.d.ts.map +1 -0
  128. package/dist/styles.css +5 -0
  129. package/dist/ui/alert-dialog/AlertDialog.vue.d.ts +18 -0
  130. package/dist/ui/alert-dialog/AlertDialog.vue.d.ts.map +1 -0
  131. package/dist/ui/alert-dialog/AlertDialogAction.vue.d.ts +18 -0
  132. package/dist/ui/alert-dialog/AlertDialogAction.vue.d.ts.map +1 -0
  133. package/dist/ui/alert-dialog/AlertDialogCancel.vue.d.ts +18 -0
  134. package/dist/ui/alert-dialog/AlertDialogCancel.vue.d.ts.map +1 -0
  135. package/dist/ui/alert-dialog/AlertDialogContent.vue.d.ts +32 -0
  136. package/dist/ui/alert-dialog/AlertDialogContent.vue.d.ts.map +1 -0
  137. package/dist/ui/alert-dialog/AlertDialogDescription.vue.d.ts +18 -0
  138. package/dist/ui/alert-dialog/AlertDialogDescription.vue.d.ts.map +1 -0
  139. package/dist/ui/alert-dialog/AlertDialogFooter.vue.d.ts +17 -0
  140. package/dist/ui/alert-dialog/AlertDialogFooter.vue.d.ts.map +1 -0
  141. package/dist/ui/alert-dialog/AlertDialogHeader.vue.d.ts +17 -0
  142. package/dist/ui/alert-dialog/AlertDialogHeader.vue.d.ts.map +1 -0
  143. package/dist/ui/alert-dialog/AlertDialogTitle.vue.d.ts +18 -0
  144. package/dist/ui/alert-dialog/AlertDialogTitle.vue.d.ts.map +1 -0
  145. package/dist/ui/alert-dialog/AlertDialogTrigger.vue.d.ts +14 -0
  146. package/dist/ui/alert-dialog/AlertDialogTrigger.vue.d.ts.map +1 -0
  147. package/dist/ui/alert-dialog/index.d.ts +10 -0
  148. package/dist/ui/alert-dialog/index.d.ts.map +1 -0
  149. package/dist/ui/badge/Badge.vue.d.ts +19 -0
  150. package/dist/ui/badge/Badge.vue.d.ts.map +1 -0
  151. package/dist/ui/badge/index.d.ts +7 -0
  152. package/dist/ui/badge/index.d.ts.map +1 -0
  153. package/dist/ui/button/Button.vue.d.ts +23 -0
  154. package/dist/ui/button/Button.vue.d.ts.map +1 -0
  155. package/dist/ui/button/index.d.ts +9 -0
  156. package/dist/ui/button/index.d.ts.map +1 -0
  157. package/dist/ui/card/Card.vue.d.ts +17 -0
  158. package/dist/ui/card/Card.vue.d.ts.map +1 -0
  159. package/dist/ui/card/CardContent.vue.d.ts +17 -0
  160. package/dist/ui/card/CardContent.vue.d.ts.map +1 -0
  161. package/dist/ui/card/CardDescription.vue.d.ts +17 -0
  162. package/dist/ui/card/CardDescription.vue.d.ts.map +1 -0
  163. package/dist/ui/card/CardFooter.vue.d.ts +17 -0
  164. package/dist/ui/card/CardFooter.vue.d.ts.map +1 -0
  165. package/dist/ui/card/CardHeader.vue.d.ts +17 -0
  166. package/dist/ui/card/CardHeader.vue.d.ts.map +1 -0
  167. package/dist/ui/card/CardTitle.vue.d.ts +17 -0
  168. package/dist/ui/card/CardTitle.vue.d.ts.map +1 -0
  169. package/dist/ui/card/index.d.ts +7 -0
  170. package/dist/ui/card/index.d.ts.map +1 -0
  171. package/dist/ui/checkbox/Checkbox.vue.d.ts +30 -0
  172. package/dist/ui/checkbox/Checkbox.vue.d.ts.map +1 -0
  173. package/dist/ui/checkbox/index.d.ts +2 -0
  174. package/dist/ui/checkbox/index.d.ts.map +1 -0
  175. package/dist/ui/dialog/Dialog.vue.d.ts +18 -0
  176. package/dist/ui/dialog/Dialog.vue.d.ts.map +1 -0
  177. package/dist/ui/dialog/DialogClose.vue.d.ts +14 -0
  178. package/dist/ui/dialog/DialogClose.vue.d.ts.map +1 -0
  179. package/dist/ui/dialog/DialogContent.vue.d.ts +32 -0
  180. package/dist/ui/dialog/DialogContent.vue.d.ts.map +1 -0
  181. package/dist/ui/dialog/DialogDescription.vue.d.ts +18 -0
  182. package/dist/ui/dialog/DialogDescription.vue.d.ts.map +1 -0
  183. package/dist/ui/dialog/DialogFooter.vue.d.ts +17 -0
  184. package/dist/ui/dialog/DialogFooter.vue.d.ts.map +1 -0
  185. package/dist/ui/dialog/DialogHeader.vue.d.ts +17 -0
  186. package/dist/ui/dialog/DialogHeader.vue.d.ts.map +1 -0
  187. package/dist/ui/dialog/DialogScrollContent.vue.d.ts +32 -0
  188. package/dist/ui/dialog/DialogScrollContent.vue.d.ts.map +1 -0
  189. package/dist/ui/dialog/DialogTitle.vue.d.ts +18 -0
  190. package/dist/ui/dialog/DialogTitle.vue.d.ts.map +1 -0
  191. package/dist/ui/dialog/DialogTrigger.vue.d.ts +14 -0
  192. package/dist/ui/dialog/DialogTrigger.vue.d.ts.map +1 -0
  193. package/dist/ui/dialog/index.d.ts +10 -0
  194. package/dist/ui/dialog/index.d.ts.map +1 -0
  195. package/dist/ui/dropdown-menu/DropdownMenu.vue.d.ts +18 -0
  196. package/dist/ui/dropdown-menu/DropdownMenu.vue.d.ts.map +1 -0
  197. package/dist/ui/dropdown-menu/DropdownMenuCheckboxItem.vue.d.ts +24 -0
  198. package/dist/ui/dropdown-menu/DropdownMenuCheckboxItem.vue.d.ts.map +1 -0
  199. package/dist/ui/dropdown-menu/DropdownMenuContent.vue.d.ts +32 -0
  200. package/dist/ui/dropdown-menu/DropdownMenuContent.vue.d.ts.map +1 -0
  201. package/dist/ui/dropdown-menu/DropdownMenuGroup.vue.d.ts +14 -0
  202. package/dist/ui/dropdown-menu/DropdownMenuGroup.vue.d.ts.map +1 -0
  203. package/dist/ui/dropdown-menu/DropdownMenuItem.vue.d.ts +19 -0
  204. package/dist/ui/dropdown-menu/DropdownMenuItem.vue.d.ts.map +1 -0
  205. package/dist/ui/dropdown-menu/DropdownMenuLabel.vue.d.ts +19 -0
  206. package/dist/ui/dropdown-menu/DropdownMenuLabel.vue.d.ts.map +1 -0
  207. package/dist/ui/dropdown-menu/DropdownMenuRadioGroup.vue.d.ts +18 -0
  208. package/dist/ui/dropdown-menu/DropdownMenuRadioGroup.vue.d.ts.map +1 -0
  209. package/dist/ui/dropdown-menu/DropdownMenuRadioItem.vue.d.ts +22 -0
  210. package/dist/ui/dropdown-menu/DropdownMenuRadioItem.vue.d.ts.map +1 -0
  211. package/dist/ui/dropdown-menu/DropdownMenuSeparator.vue.d.ts +8 -0
  212. package/dist/ui/dropdown-menu/DropdownMenuSeparator.vue.d.ts.map +1 -0
  213. package/dist/ui/dropdown-menu/DropdownMenuShortcut.vue.d.ts +17 -0
  214. package/dist/ui/dropdown-menu/DropdownMenuShortcut.vue.d.ts.map +1 -0
  215. package/dist/ui/dropdown-menu/DropdownMenuSub.vue.d.ts +18 -0
  216. package/dist/ui/dropdown-menu/DropdownMenuSub.vue.d.ts.map +1 -0
  217. package/dist/ui/dropdown-menu/DropdownMenuSubContent.vue.d.ts +34 -0
  218. package/dist/ui/dropdown-menu/DropdownMenuSubContent.vue.d.ts.map +1 -0
  219. package/dist/ui/dropdown-menu/DropdownMenuSubTrigger.vue.d.ts +18 -0
  220. package/dist/ui/dropdown-menu/DropdownMenuSubTrigger.vue.d.ts.map +1 -0
  221. package/dist/ui/dropdown-menu/DropdownMenuTrigger.vue.d.ts +14 -0
  222. package/dist/ui/dropdown-menu/DropdownMenuTrigger.vue.d.ts.map +1 -0
  223. package/dist/ui/dropdown-menu/index.d.ts +16 -0
  224. package/dist/ui/dropdown-menu/index.d.ts.map +1 -0
  225. package/dist/ui/input/Input.vue.d.ts +13 -0
  226. package/dist/ui/input/Input.vue.d.ts.map +1 -0
  227. package/dist/ui/input/index.d.ts +2 -0
  228. package/dist/ui/input/index.d.ts.map +1 -0
  229. package/dist/ui/label/Label.vue.d.ts +18 -0
  230. package/dist/ui/label/Label.vue.d.ts.map +1 -0
  231. package/dist/ui/label/index.d.ts +2 -0
  232. package/dist/ui/label/index.d.ts.map +1 -0
  233. package/dist/ui/responsive-dialog/ResponsiveDialog.vue.d.ts +32 -0
  234. package/dist/ui/responsive-dialog/ResponsiveDialog.vue.d.ts.map +1 -0
  235. package/dist/ui/responsive-dialog/index.d.ts +2 -0
  236. package/dist/ui/responsive-dialog/index.d.ts.map +1 -0
  237. package/dist/ui/scroll-area/ScrollArea.vue.d.ts +18 -0
  238. package/dist/ui/scroll-area/ScrollArea.vue.d.ts.map +1 -0
  239. package/dist/ui/scroll-area/ScrollBar.vue.d.ts +10 -0
  240. package/dist/ui/scroll-area/ScrollBar.vue.d.ts.map +1 -0
  241. package/dist/ui/scroll-area/index.d.ts +3 -0
  242. package/dist/ui/scroll-area/index.d.ts.map +1 -0
  243. package/dist/ui/select/Select.vue.d.ts +21 -0
  244. package/dist/ui/select/Select.vue.d.ts.map +1 -0
  245. package/dist/ui/select/SelectContent.vue.d.ts +28 -0
  246. package/dist/ui/select/SelectContent.vue.d.ts.map +1 -0
  247. package/dist/ui/select/SelectGroup.vue.d.ts +18 -0
  248. package/dist/ui/select/SelectGroup.vue.d.ts.map +1 -0
  249. package/dist/ui/select/SelectItem.vue.d.ts +18 -0
  250. package/dist/ui/select/SelectItem.vue.d.ts.map +1 -0
  251. package/dist/ui/select/SelectItemText.vue.d.ts +14 -0
  252. package/dist/ui/select/SelectItemText.vue.d.ts.map +1 -0
  253. package/dist/ui/select/SelectLabel.vue.d.ts +18 -0
  254. package/dist/ui/select/SelectLabel.vue.d.ts.map +1 -0
  255. package/dist/ui/select/SelectScrollDownButton.vue.d.ts +18 -0
  256. package/dist/ui/select/SelectScrollDownButton.vue.d.ts.map +1 -0
  257. package/dist/ui/select/SelectScrollUpButton.vue.d.ts +18 -0
  258. package/dist/ui/select/SelectScrollUpButton.vue.d.ts.map +1 -0
  259. package/dist/ui/select/SelectSeparator.vue.d.ts +8 -0
  260. package/dist/ui/select/SelectSeparator.vue.d.ts.map +1 -0
  261. package/dist/ui/select/SelectTrigger.vue.d.ts +18 -0
  262. package/dist/ui/select/SelectTrigger.vue.d.ts.map +1 -0
  263. package/dist/ui/select/SelectValue.vue.d.ts +14 -0
  264. package/dist/ui/select/SelectValue.vue.d.ts.map +1 -0
  265. package/dist/ui/select/index.d.ts +12 -0
  266. package/dist/ui/select/index.d.ts.map +1 -0
  267. package/dist/ui/sheet/Sheet.vue.d.ts +18 -0
  268. package/dist/ui/sheet/Sheet.vue.d.ts.map +1 -0
  269. package/dist/ui/sheet/SheetClose.vue.d.ts +14 -0
  270. package/dist/ui/sheet/SheetClose.vue.d.ts.map +1 -0
  271. package/dist/ui/sheet/SheetContent.vue.d.ts +34 -0
  272. package/dist/ui/sheet/SheetContent.vue.d.ts.map +1 -0
  273. package/dist/ui/sheet/SheetDescription.vue.d.ts +18 -0
  274. package/dist/ui/sheet/SheetDescription.vue.d.ts.map +1 -0
  275. package/dist/ui/sheet/SheetFooter.vue.d.ts +17 -0
  276. package/dist/ui/sheet/SheetFooter.vue.d.ts.map +1 -0
  277. package/dist/ui/sheet/SheetHeader.vue.d.ts +17 -0
  278. package/dist/ui/sheet/SheetHeader.vue.d.ts.map +1 -0
  279. package/dist/ui/sheet/SheetTitle.vue.d.ts +18 -0
  280. package/dist/ui/sheet/SheetTitle.vue.d.ts.map +1 -0
  281. package/dist/ui/sheet/SheetTrigger.vue.d.ts +14 -0
  282. package/dist/ui/sheet/SheetTrigger.vue.d.ts.map +1 -0
  283. package/dist/ui/sheet/index.d.ts +14 -0
  284. package/dist/ui/sheet/index.d.ts.map +1 -0
  285. package/dist/ui/switch/Switch.vue.d.ts +23 -0
  286. package/dist/ui/switch/Switch.vue.d.ts.map +1 -0
  287. package/dist/ui/switch/index.d.ts +2 -0
  288. package/dist/ui/switch/index.d.ts.map +1 -0
  289. package/dist/ui/textarea/Textarea.vue.d.ts +13 -0
  290. package/dist/ui/textarea/Textarea.vue.d.ts.map +1 -0
  291. package/dist/ui/textarea/index.d.ts +2 -0
  292. package/dist/ui/textarea/index.d.ts.map +1 -0
  293. package/dist/ui/toast/Toast.vue.d.ts +96 -0
  294. package/dist/ui/toast/Toast.vue.d.ts.map +1 -0
  295. package/dist/ui/toast/ToastAction.vue.d.ts +18 -0
  296. package/dist/ui/toast/ToastAction.vue.d.ts.map +1 -0
  297. package/dist/ui/toast/ToastClose.vue.d.ts +8 -0
  298. package/dist/ui/toast/ToastClose.vue.d.ts.map +1 -0
  299. package/dist/ui/toast/ToastDescription.vue.d.ts +18 -0
  300. package/dist/ui/toast/ToastDescription.vue.d.ts.map +1 -0
  301. package/dist/ui/toast/ToastProvider.vue.d.ts +14 -0
  302. package/dist/ui/toast/ToastProvider.vue.d.ts.map +1 -0
  303. package/dist/ui/toast/ToastTitle.vue.d.ts +18 -0
  304. package/dist/ui/toast/ToastTitle.vue.d.ts.map +1 -0
  305. package/dist/ui/toast/ToastViewport.vue.d.ts +8 -0
  306. package/dist/ui/toast/ToastViewport.vue.d.ts.map +1 -0
  307. package/dist/ui/toast/Toaster.vue.d.ts +3 -0
  308. package/dist/ui/toast/Toaster.vue.d.ts.map +1 -0
  309. package/dist/ui/toast/index.d.ts +23 -0
  310. package/dist/ui/toast/index.d.ts.map +1 -0
  311. package/dist/ui/toast/use-toast.d.ts +23 -0
  312. package/dist/ui/toast/use-toast.d.ts.map +1 -0
  313. package/dist/ui/tooltip/Tooltip.vue.d.ts +18 -0
  314. package/dist/ui/tooltip/Tooltip.vue.d.ts.map +1 -0
  315. package/dist/ui/tooltip/TooltipContent.vue.d.ts +26 -0
  316. package/dist/ui/tooltip/TooltipContent.vue.d.ts.map +1 -0
  317. package/dist/ui/tooltip/TooltipProvider.vue.d.ts +14 -0
  318. package/dist/ui/tooltip/TooltipProvider.vue.d.ts.map +1 -0
  319. package/dist/ui/tooltip/TooltipTrigger.vue.d.ts +14 -0
  320. package/dist/ui/tooltip/TooltipTrigger.vue.d.ts.map +1 -0
  321. package/dist/ui/tooltip/index.d.ts +5 -0
  322. package/dist/ui/tooltip/index.d.ts.map +1 -0
  323. package/dist/ui/utils.d.ts +2 -0
  324. package/dist/ui/utils.d.ts.map +1 -0
  325. package/dist/vue.css +1 -0
  326. package/package.json +64 -0
  327. package/src/appearance.ts +568 -0
  328. package/src/components/chat/AnimatedStreamBlock.vue +94 -0
  329. package/src/components/chat/ChatHistoryDropdown.vue +226 -0
  330. package/src/components/chat/ChatInput.vue +571 -0
  331. package/src/components/chat/ChatMessageActivityBlock.vue +447 -0
  332. package/src/components/chat/ChatMessageItem.vue +357 -0
  333. package/src/components/chat/ChatMessageList.vue +178 -0
  334. package/src/components/chat/ChatPendingIndicator.vue +163 -0
  335. package/src/components/chat/ReasoningStream.vue +112 -0
  336. package/src/components/chat/index.ts +8 -0
  337. package/src/components/shell/SvedaAgentCompletedNotice.vue +25 -0
  338. package/src/components/shell/SvedaAgentTasksPanel.vue +146 -0
  339. package/src/components/shell/SvedaChat.vue +514 -0
  340. package/src/components/shell/SvedaContextUsageBar.vue +33 -0
  341. package/src/components/shell/SvedaHistorySheet.vue +52 -0
  342. package/src/components/shell/SvedaHistorySidebar.vue +41 -0
  343. package/src/components/shell/SvedaInputSection.vue +53 -0
  344. package/src/components/shell/SvedaLandingView.vue +93 -0
  345. package/src/components/shell/SvedaMaxStepsNotice.vue +33 -0
  346. package/src/components/shell/SvedaMinimizedTrigger.vue +43 -0
  347. package/src/components/shell/SvedaModelControls.vue +47 -0
  348. package/src/components/shell/SvedaModelSelect.vue +32 -0
  349. package/src/components/shell/SvedaQuickPrompts.vue +44 -0
  350. package/src/components/shell/SvedaResizeHandles.vue +31 -0
  351. package/src/components/shell/SvedaTabs.vue +123 -0
  352. package/src/components/shell/SvedaToolbar.vue +171 -0
  353. package/src/composables/useSvedaAgentTasks.ts +93 -0
  354. package/src/composables/useSvedaBootstrap.ts +36 -0
  355. package/src/composables/useSvedaChat.ts +593 -0
  356. package/src/composables/useSvedaChatLayout.ts +539 -0
  357. package/src/composables/useSvedaChatPage.ts +339 -0
  358. package/src/composables/useSvedaContextWindow.ts +31 -0
  359. package/src/composables/useSvedaDocuments.ts +115 -0
  360. package/src/composables/useSvedaMaxStepsContinue.ts +68 -0
  361. package/src/composables/useSvedaMessaging.ts +99 -0
  362. package/src/composables/useSvedaModel.ts +85 -0
  363. package/src/composables/useSvedaPrompts.ts +59 -0
  364. package/src/composables/useSvedaReadable.ts +33 -0
  365. package/src/composables/useSvedaScroll.ts +93 -0
  366. package/src/composables/useSvedaShell.ts +91 -0
  367. package/src/composables/useSvedaStreaming.ts +408 -0
  368. package/src/composables/useSvedaTool.ts +18 -0
  369. package/src/i18n/index.ts +72 -0
  370. package/src/i18n/locales/en.ts +58 -0
  371. package/src/i18n/locales/ru.ts +59 -0
  372. package/src/index.ts +141 -0
  373. package/src/launcherIcons.ts +39 -0
  374. package/src/lib/assistantMessage.ts +437 -0
  375. package/src/lib/chatHistoryMerge.ts +93 -0
  376. package/src/lib/chatI18nKeys.ts +62 -0
  377. package/src/lib/chatMessageVisibility.ts +50 -0
  378. package/src/lib/chatTabs.ts +54 -0
  379. package/src/lib/chatTitle.ts +30 -0
  380. package/src/lib/chatUiStorage.ts +33 -0
  381. package/src/lib/finalizeMessages.ts +81 -0
  382. package/src/lib/markdown.ts +90 -0
  383. package/src/lib/modelLabels.ts +24 -0
  384. package/src/lib/pendingStatusRotation.ts +26 -0
  385. package/src/lib/shims-vue.d.ts +6 -0
  386. package/src/lib/useAnimatedText.ts +78 -0
  387. package/src/lib/userMessage.ts +55 -0
  388. package/src/lib/utils.ts +6 -0
  389. package/src/plugin.ts +164 -0
  390. package/src/styles.css +5 -0
  391. package/src/theme.css +95 -0
  392. package/src/theme.test.mjs +80 -0
  393. package/src/ui/alert-dialog/AlertDialog.vue +14 -0
  394. package/src/ui/alert-dialog/AlertDialogAction.vue +17 -0
  395. package/src/ui/alert-dialog/AlertDialogCancel.vue +24 -0
  396. package/src/ui/alert-dialog/AlertDialogContent.vue +39 -0
  397. package/src/ui/alert-dialog/AlertDialogDescription.vue +22 -0
  398. package/src/ui/alert-dialog/AlertDialogFooter.vue +21 -0
  399. package/src/ui/alert-dialog/AlertDialogHeader.vue +16 -0
  400. package/src/ui/alert-dialog/AlertDialogTitle.vue +19 -0
  401. package/src/ui/alert-dialog/AlertDialogTrigger.vue +11 -0
  402. package/src/ui/alert-dialog/index.ts +9 -0
  403. package/src/ui/badge/Badge.vue +16 -0
  404. package/src/ui/badge/index.ts +27 -0
  405. package/src/ui/button/Button.vue +56 -0
  406. package/src/ui/button/index.ts +50 -0
  407. package/src/ui/card/Card.vue +14 -0
  408. package/src/ui/card/CardContent.vue +14 -0
  409. package/src/ui/card/CardDescription.vue +14 -0
  410. package/src/ui/card/CardFooter.vue +14 -0
  411. package/src/ui/card/CardHeader.vue +14 -0
  412. package/src/ui/card/CardTitle.vue +14 -0
  413. package/src/ui/card/index.ts +6 -0
  414. package/src/ui/checkbox/Checkbox.vue +41 -0
  415. package/src/ui/checkbox/index.ts +1 -0
  416. package/src/ui/dialog/Dialog.vue +14 -0
  417. package/src/ui/dialog/DialogClose.vue +11 -0
  418. package/src/ui/dialog/DialogContent.vue +50 -0
  419. package/src/ui/dialog/DialogDescription.vue +24 -0
  420. package/src/ui/dialog/DialogFooter.vue +19 -0
  421. package/src/ui/dialog/DialogHeader.vue +16 -0
  422. package/src/ui/dialog/DialogScrollContent.vue +59 -0
  423. package/src/ui/dialog/DialogTitle.vue +29 -0
  424. package/src/ui/dialog/DialogTrigger.vue +11 -0
  425. package/src/ui/dialog/index.ts +9 -0
  426. package/src/ui/dropdown-menu/DropdownMenu.vue +14 -0
  427. package/src/ui/dropdown-menu/DropdownMenuCheckboxItem.vue +42 -0
  428. package/src/ui/dropdown-menu/DropdownMenuContent.vue +40 -0
  429. package/src/ui/dropdown-menu/DropdownMenuGroup.vue +11 -0
  430. package/src/ui/dropdown-menu/DropdownMenuItem.vue +30 -0
  431. package/src/ui/dropdown-menu/DropdownMenuLabel.vue +21 -0
  432. package/src/ui/dropdown-menu/DropdownMenuRadioGroup.vue +14 -0
  433. package/src/ui/dropdown-menu/DropdownMenuRadioItem.vue +43 -0
  434. package/src/ui/dropdown-menu/DropdownMenuSeparator.vue +21 -0
  435. package/src/ui/dropdown-menu/DropdownMenuShortcut.vue +14 -0
  436. package/src/ui/dropdown-menu/DropdownMenuSub.vue +14 -0
  437. package/src/ui/dropdown-menu/DropdownMenuSubContent.vue +30 -0
  438. package/src/ui/dropdown-menu/DropdownMenuSubTrigger.vue +31 -0
  439. package/src/ui/dropdown-menu/DropdownMenuTrigger.vue +13 -0
  440. package/src/ui/dropdown-menu/index.ts +16 -0
  441. package/src/ui/input/Input.vue +32 -0
  442. package/src/ui/input/index.ts +1 -0
  443. package/src/ui/label/Label.vue +22 -0
  444. package/src/ui/label/index.ts +1 -0
  445. package/src/ui/responsive-dialog/ResponsiveDialog.vue +55 -0
  446. package/src/ui/responsive-dialog/index.ts +1 -0
  447. package/src/ui/scroll-area/ScrollArea.vue +29 -0
  448. package/src/ui/scroll-area/ScrollBar.vue +30 -0
  449. package/src/ui/scroll-area/index.ts +2 -0
  450. package/src/ui/select/Select.vue +15 -0
  451. package/src/ui/select/SelectContent.vue +53 -0
  452. package/src/ui/select/SelectGroup.vue +19 -0
  453. package/src/ui/select/SelectItem.vue +44 -0
  454. package/src/ui/select/SelectItemText.vue +11 -0
  455. package/src/ui/select/SelectLabel.vue +13 -0
  456. package/src/ui/select/SelectScrollDownButton.vue +24 -0
  457. package/src/ui/select/SelectScrollUpButton.vue +24 -0
  458. package/src/ui/select/SelectSeparator.vue +17 -0
  459. package/src/ui/select/SelectTrigger.vue +31 -0
  460. package/src/ui/select/SelectValue.vue +11 -0
  461. package/src/ui/select/index.ts +11 -0
  462. package/src/ui/sheet/Sheet.vue +14 -0
  463. package/src/ui/sheet/SheetClose.vue +11 -0
  464. package/src/ui/sheet/SheetContent.vue +53 -0
  465. package/src/ui/sheet/SheetDescription.vue +19 -0
  466. package/src/ui/sheet/SheetFooter.vue +12 -0
  467. package/src/ui/sheet/SheetHeader.vue +12 -0
  468. package/src/ui/sheet/SheetTitle.vue +19 -0
  469. package/src/ui/sheet/SheetTrigger.vue +11 -0
  470. package/src/ui/sheet/index.ts +29 -0
  471. package/src/ui/switch/Switch.vue +55 -0
  472. package/src/ui/switch/index.ts +1 -0
  473. package/src/ui/textarea/Textarea.vue +24 -0
  474. package/src/ui/textarea/index.ts +1 -0
  475. package/src/ui/toast/Toast.vue +28 -0
  476. package/src/ui/toast/ToastAction.vue +19 -0
  477. package/src/ui/toast/ToastClose.vue +22 -0
  478. package/src/ui/toast/ToastDescription.vue +19 -0
  479. package/src/ui/toast/ToastProvider.vue +11 -0
  480. package/src/ui/toast/ToastTitle.vue +19 -0
  481. package/src/ui/toast/ToastViewport.vue +17 -0
  482. package/src/ui/toast/Toaster.vue +48 -0
  483. package/src/ui/toast/index.ts +39 -0
  484. package/src/ui/toast/use-toast.ts +109 -0
  485. package/src/ui/tooltip/Tooltip.vue +14 -0
  486. package/src/ui/tooltip/TooltipContent.vue +39 -0
  487. package/src/ui/tooltip/TooltipProvider.vue +11 -0
  488. package/src/ui/tooltip/TooltipTrigger.vue +11 -0
  489. package/src/ui/tooltip/index.ts +4 -0
  490. package/src/ui/utils.ts +1 -0
@@ -0,0 +1,93 @@
1
+ import { computed, onUnmounted, ref } from 'vue';
2
+
3
+ export type SvedaAgentTaskItem = {
4
+ id: string;
5
+ type: string;
6
+ label: string;
7
+ status: string;
8
+ summary?: string;
9
+ error?: string;
10
+ };
11
+
12
+ export type SvedaAgentTasksState = {
13
+ runId: string | null;
14
+ phase: string;
15
+ tasks: SvedaAgentTaskItem[];
16
+ };
17
+
18
+ export type SvedaAgentTasksPayload = {
19
+ runId?: string;
20
+ phase?: string;
21
+ tasks?: Array<{
22
+ id?: unknown;
23
+ type?: unknown;
24
+ label?: unknown;
25
+ status?: unknown;
26
+ summary?: unknown;
27
+ detail?: unknown;
28
+ error?: unknown;
29
+ }>;
30
+ };
31
+
32
+ const emptyState = (): SvedaAgentTasksState => ({
33
+ runId: null,
34
+ phase: '',
35
+ tasks: [],
36
+ });
37
+
38
+ export function useSvedaAgentTasks(
39
+ options: {
40
+ subscribe?: (
41
+ onPayload: (payload: SvedaAgentTasksPayload) => void
42
+ ) => void | (() => void);
43
+ } = {}
44
+ ) {
45
+ const state = ref<SvedaAgentTasksState>(emptyState());
46
+
47
+ const hasActiveTasks = computed(() =>
48
+ state.value.tasks.some(task => task.status === 'running' || task.status === 'pending')
49
+ );
50
+
51
+ const mergePayload = (payload: SvedaAgentTasksPayload) => {
52
+ if (!payload || !Array.isArray(payload.tasks)) {
53
+ return;
54
+ }
55
+
56
+ state.value = {
57
+ runId: payload.runId ?? state.value.runId,
58
+ phase: payload.phase ?? state.value.phase,
59
+ tasks: payload.tasks.map(task => ({
60
+ id: String(task.id ?? ''),
61
+ type: String(task.type ?? task.label ?? ''),
62
+ label: String(task.label ?? task.type ?? ''),
63
+ status: String(task.status ?? 'pending'),
64
+ summary:
65
+ task.summary !== undefined && task.summary !== null
66
+ ? String(task.summary)
67
+ : task.detail !== undefined && task.detail !== null
68
+ ? String(task.detail)
69
+ : undefined,
70
+ error: task.error ? String(task.error) : undefined,
71
+ })),
72
+ };
73
+ };
74
+
75
+ const clearTasks = () => {
76
+ state.value = emptyState();
77
+ };
78
+
79
+ const stopSubscribe = options.subscribe?.(mergePayload) ?? null;
80
+
81
+ onUnmounted(() => {
82
+ if (typeof stopSubscribe === 'function') {
83
+ stopSubscribe();
84
+ }
85
+ });
86
+
87
+ return {
88
+ agentTasks: state,
89
+ hasActiveAgentTasks: hasActiveTasks,
90
+ clearAgentTasks: clearTasks,
91
+ mergeAgentTasksPayload: mergePayload,
92
+ };
93
+ }
@@ -0,0 +1,36 @@
1
+ import { nextTick, type Ref } from 'vue';
2
+
3
+ const PAGE_SESSION_BOOT_KEY = '__SVEDA_CHAT_PAGE_BOOTED__';
4
+
5
+ type SortedHistory = { id: string };
6
+
7
+ export function useSvedaBootstrap(deps: {
8
+ loadHistories: () => Promise<void>;
9
+ createNewChat: () => void;
10
+ setCurrentChat: (id: string) => Promise<void>;
11
+ currentChat: Ref<{ id?: string } | null | undefined>;
12
+ sortedHistories: Ref<SortedHistory[]>;
13
+ scrollToBottom: () => void;
14
+ }) {
15
+ const loadChatBootstrap = async () => {
16
+ await deps.loadHistories();
17
+ const globalScope = window as unknown as Record<string, unknown>;
18
+ const isPageBooted = Boolean(globalScope[PAGE_SESSION_BOOT_KEY]);
19
+ if (!isPageBooted) {
20
+ globalScope[PAGE_SESSION_BOOT_KEY] = true;
21
+ deps.createNewChat();
22
+ } else if (!deps.currentChat.value) {
23
+ if (deps.sortedHistories.value.length > 0) {
24
+ await deps.setCurrentChat(deps.sortedHistories.value[0].id);
25
+ } else {
26
+ deps.createNewChat();
27
+ }
28
+ }
29
+ await nextTick();
30
+ deps.scrollToBottom();
31
+ };
32
+
33
+ return {
34
+ loadChatBootstrap,
35
+ };
36
+ }
@@ -0,0 +1,593 @@
1
+ import {
2
+ createMessageId,
3
+ type SvedaChatHistorySummary,
4
+ type SvedaClient,
5
+ type SvedaDisplayMessage,
6
+ } from '@sveda-ai/core';
7
+ import { computed, inject, reactive, readonly, ref } from 'vue';
8
+ import { useSvedaT } from '../i18n/index';
9
+ import {
10
+ mergeServerChatHistories,
11
+ resolveMergedCurrentChat,
12
+ upsertChatHistoryMessages,
13
+ } from '../lib/chatHistoryMerge';
14
+ import { readPersistedMinimized, writePersistedMinimized } from '../lib/chatUiStorage';
15
+ import {
16
+ finalizeMessagesForDisplay,
17
+ type SvedaFinalizableMessage,
18
+ } from '../lib/finalizeMessages';
19
+ import { getUserMessageAttachmentNames, getUserMessageText } from '../lib/userMessage';
20
+ import { SvedaClientKey } from '../plugin';
21
+
22
+ export interface SvedaChatHistory {
23
+ id: string;
24
+ title: string;
25
+ preview?: string;
26
+ messages: SvedaDisplayMessage[];
27
+ tokensUsed: number;
28
+ contextWindowTokens: number;
29
+ createdAt: number;
30
+ updatedAt: number;
31
+ messagesLoaded: boolean;
32
+ }
33
+
34
+ export interface SvedaChatState {
35
+ isOpen: boolean;
36
+ isMinimized: boolean;
37
+ currentChatId: string | null;
38
+ isLoading: boolean;
39
+ isLoadingChatHistory: boolean;
40
+ }
41
+
42
+ const initialIsMinimized = readPersistedMinimized();
43
+
44
+ const chatState = reactive<SvedaChatState>({
45
+ isOpen: !initialIsMinimized,
46
+ isMinimized: initialIsMinimized,
47
+ currentChatId: null,
48
+ isLoading: false,
49
+ isLoadingChatHistory: false,
50
+ });
51
+
52
+ const chatHistories = ref<SvedaChatHistory[]>([]);
53
+ const currentChat = ref<SvedaChatHistory | null>(null);
54
+ const openChatTabIds = ref<string[]>([]);
55
+
56
+ let activeClient: SvedaClient | null = null;
57
+ let initialized = false;
58
+
59
+ const hasUserRequests = (chat: SvedaChatHistory): boolean => {
60
+ if (typeof chat.preview === 'string' && chat.preview.trim().length > 0) {
61
+ return true;
62
+ }
63
+
64
+ return chat.messages.some(message => {
65
+ if (message.role !== 'user') {
66
+ return false;
67
+ }
68
+
69
+ const body = getUserMessageText(message);
70
+ const hasFiles = getUserMessageAttachmentNames(message).length > 0;
71
+ return body.length > 0 || hasFiles;
72
+ });
73
+ };
74
+
75
+ const isServerSummary = (chat: SvedaChatHistory): boolean => !chat.messagesLoaded;
76
+
77
+ const shouldIncludeInHistoryList = (chat: SvedaChatHistory): boolean => {
78
+ return hasUserRequests(chat) || isServerSummary(chat);
79
+ };
80
+
81
+ const generateChatId = (): string => `chat_${createMessageId()}`;
82
+
83
+ const ensureChatTab = (chatId: string) => {
84
+ if (!openChatTabIds.value.includes(chatId)) {
85
+ openChatTabIds.value = [...openChatTabIds.value, chatId];
86
+ }
87
+ };
88
+
89
+ const removeChatTab = (chatId: string) => {
90
+ openChatTabIds.value = openChatTabIds.value.filter(id => id !== chatId);
91
+ };
92
+
93
+ const toTimestamp = (value: unknown): number => {
94
+ if (typeof value === 'number' && Number.isFinite(value)) {
95
+ return value;
96
+ }
97
+ if (typeof value === 'string') {
98
+ const parsed = Date.parse(value);
99
+ if (!Number.isNaN(parsed)) {
100
+ return parsed;
101
+ }
102
+ }
103
+ return Date.now();
104
+ };
105
+
106
+ const finalizeForDisplay = (messages: unknown): SvedaDisplayMessage[] => {
107
+ const list = Array.isArray(messages) ? (messages as SvedaFinalizableMessage[]) : [];
108
+ return finalizeMessagesForDisplay(list) as unknown as SvedaDisplayMessage[];
109
+ };
110
+
111
+ const resolveServerHistoryId = (history: SvedaChatHistorySummary): string => {
112
+ const fromChatId = typeof history.chatId === 'string' ? history.chatId.trim() : '';
113
+ if (fromChatId !== '') {
114
+ return fromChatId;
115
+ }
116
+
117
+ const fromId = typeof history.id === 'string' ? history.id.trim() : '';
118
+ return fromId;
119
+ };
120
+
121
+ const mapServerHistory = (
122
+ history: SvedaChatHistorySummary & { messages?: unknown },
123
+ messagesLoaded: boolean
124
+ ): SvedaChatHistory => ({
125
+ id: resolveServerHistoryId(history),
126
+ title: history.title || '',
127
+ preview: typeof history.preview === 'string' ? history.preview : '',
128
+ messages: messagesLoaded ? finalizeForDisplay(history.messages) : [],
129
+ tokensUsed: Number(history.tokensUsed) || 0,
130
+ contextWindowTokens: Number(history.contextWindowTokens) || 0,
131
+ createdAt: toTimestamp(history.createdAt),
132
+ updatedAt: toTimestamp(history.updatedAt),
133
+ messagesLoaded,
134
+ });
135
+
136
+ const historiesEndpointConfigured = (): boolean => Boolean(activeClient?.endpoints.histories);
137
+
138
+ const fetchHistoriesFromServer = async (): Promise<SvedaChatHistory[]> => {
139
+ if (!activeClient || !historiesEndpointConfigured()) {
140
+ return [];
141
+ }
142
+
143
+ try {
144
+ const histories = await activeClient.listHistories();
145
+ return histories.map(history => mapServerHistory(history, false));
146
+ } catch (err) {
147
+ console.error('Error loading chat histories from server:', err);
148
+ return [];
149
+ }
150
+ };
151
+
152
+ const fetchChatHistoryFromServer = async (chatId: string): Promise<SvedaChatHistory | null> => {
153
+ if (!activeClient || !historiesEndpointConfigured()) {
154
+ return null;
155
+ }
156
+
157
+ try {
158
+ const detail = await activeClient.getHistory(chatId);
159
+ return mapServerHistory(detail, true);
160
+ } catch (err) {
161
+ console.error('Error loading chat history from server:', err);
162
+ return null;
163
+ }
164
+ };
165
+
166
+ const deleteChatOnServer = async (chatId: string) => {
167
+ if (!activeClient || !historiesEndpointConfigured()) {
168
+ return;
169
+ }
170
+
171
+ try {
172
+ await activeClient.deleteHistory(chatId);
173
+ } catch (err) {
174
+ console.error('Error deleting chat history from server:', err);
175
+ }
176
+ };
177
+
178
+ const renameChatOnServer = async (chatId: string, title: string) => {
179
+ if (!activeClient || !historiesEndpointConfigured()) {
180
+ return;
181
+ }
182
+
183
+ try {
184
+ await activeClient.renameHistory(chatId, title);
185
+ } catch (err) {
186
+ console.error('Error renaming chat history on server:', err);
187
+ }
188
+ };
189
+
190
+ const buildWelcomeMessage = (text: string): SvedaDisplayMessage => ({
191
+ id: createMessageId(),
192
+ role: 'assistant',
193
+ parts: [{ type: 'text', text }],
194
+ createdAt: new Date().toISOString(),
195
+ });
196
+
197
+ const loadHistories = async () => {
198
+ const serverHistories = await fetchHistoriesFromServer();
199
+
200
+ chatHistories.value = mergeServerChatHistories(serverHistories, currentChat.value);
201
+ currentChat.value = resolveMergedCurrentChat(chatHistories.value, currentChat.value);
202
+ if (currentChat.value) {
203
+ chatState.currentChatId = currentChat.value.id;
204
+ }
205
+
206
+ if (chatHistories.value.length > 0 && !currentChat.value) {
207
+ const latest = [...chatHistories.value].sort((a, b) => b.updatedAt - a.updatedAt)[0];
208
+ await setCurrentChat(latest.id);
209
+ }
210
+ };
211
+
212
+ const createNewChat = (translate?: (key: string) => string): string => {
213
+ const chatId = generateChatId();
214
+ const welcomeText = translate ? translate('welcomeMessage') : '';
215
+ const newChatTitle = translate ? translate('newChat') : 'New Chat';
216
+
217
+ const newChat: SvedaChatHistory = {
218
+ id: chatId,
219
+ title: newChatTitle,
220
+ preview: '',
221
+ messages: welcomeText ? [buildWelcomeMessage(welcomeText)] : [],
222
+ tokensUsed: 0,
223
+ contextWindowTokens: 0,
224
+ createdAt: Date.now(),
225
+ updatedAt: Date.now(),
226
+ messagesLoaded: true,
227
+ };
228
+
229
+ chatHistories.value.unshift(newChat);
230
+ ensureChatTab(chatId);
231
+ void setCurrentChat(chatId, translate);
232
+
233
+ return chatId;
234
+ };
235
+
236
+ const loadChatHistoryIfNeeded = async (chatId: string): Promise<boolean> => {
237
+ const chatIndex = chatHistories.value.findIndex(c => c.id === chatId);
238
+ if (chatIndex === -1) {
239
+ return false;
240
+ }
241
+
242
+ const chat = chatHistories.value[chatIndex];
243
+ if (chat.messagesLoaded) {
244
+ return true;
245
+ }
246
+
247
+ const loadedHistory = await fetchChatHistoryFromServer(chatId);
248
+ if (!loadedHistory) {
249
+ return false;
250
+ }
251
+
252
+ chatHistories.value[chatIndex] = {
253
+ ...loadedHistory,
254
+ preview: chat.preview || loadedHistory.preview,
255
+ };
256
+
257
+ return true;
258
+ };
259
+
260
+ const setCurrentChat = async (chatId: string, translate?: (key: string) => string) => {
261
+ chatState.isLoadingChatHistory = true;
262
+ try {
263
+ await loadChatHistoryIfNeeded(chatId);
264
+
265
+ const chatIndex = chatHistories.value.findIndex(c => c.id === chatId);
266
+ const chat = chatIndex === -1 ? undefined : chatHistories.value[chatIndex];
267
+ if (chat) {
268
+ chatHistories.value[chatIndex] = {
269
+ ...chat,
270
+ messages: finalizeForDisplay(chat.messages),
271
+ };
272
+ currentChat.value = chatHistories.value[chatIndex];
273
+ chatState.currentChatId = chatId;
274
+ ensureChatTab(chatId);
275
+ if (currentChat.value.messages.length === 0 && translate) {
276
+ const welcomeText = translate('welcomeMessage');
277
+ if (welcomeText) {
278
+ currentChat.value.messages.push(buildWelcomeMessage(welcomeText));
279
+ }
280
+ }
281
+ }
282
+ } finally {
283
+ chatState.isLoadingChatHistory = false;
284
+ }
285
+ };
286
+
287
+ const addMessage = (chatId: string, message: SvedaDisplayMessage): SvedaDisplayMessage | null => {
288
+ const chatIndex = chatHistories.value.findIndex(c => c.id === chatId);
289
+ if (chatIndex !== -1) {
290
+ const chat = chatHistories.value[chatIndex];
291
+ if (!message.createdAt) {
292
+ message.createdAt = new Date().toISOString();
293
+ }
294
+ if (!message.id) {
295
+ message.id = createMessageId();
296
+ }
297
+ chat.messages = [...chat.messages, message];
298
+ chat.messagesLoaded = true;
299
+ chat.updatedAt = Date.now();
300
+
301
+ chatHistories.value = [...chatHistories.value];
302
+
303
+ if (currentChat.value?.id === chatId) {
304
+ currentChat.value = chatHistories.value[chatIndex];
305
+ }
306
+ return message;
307
+ }
308
+ return null;
309
+ };
310
+
311
+ const setChatTitle = (chatId: string, title: string) => {
312
+ const normalizedTitle = title.trim();
313
+ if (!normalizedTitle) {
314
+ return;
315
+ }
316
+
317
+ const chatIndex = chatHistories.value.findIndex(c => c.id === chatId);
318
+ if (chatIndex === -1) {
319
+ return;
320
+ }
321
+
322
+ const chat = chatHistories.value[chatIndex];
323
+ chat.title = normalizedTitle;
324
+ chat.updatedAt = Date.now();
325
+
326
+ chatHistories.value = [...chatHistories.value];
327
+
328
+ if (currentChat.value?.id === chatId) {
329
+ currentChat.value = chatHistories.value[chatIndex];
330
+ }
331
+ };
332
+
333
+ const incrementChatTokens = (chatId: string, tokens: number) => {
334
+ const normalizedTokens = Number(tokens);
335
+ if (!Number.isFinite(normalizedTokens) || normalizedTokens <= 0) {
336
+ return;
337
+ }
338
+
339
+ const chatIndex = chatHistories.value.findIndex(c => c.id === chatId);
340
+ if (chatIndex !== -1) {
341
+ const chat = chatHistories.value[chatIndex];
342
+ chat.tokensUsed = Math.max(0, Number(chat.tokensUsed || 0) + Math.floor(normalizedTokens));
343
+ chat.updatedAt = Date.now();
344
+
345
+ chatHistories.value = [...chatHistories.value];
346
+
347
+ if (currentChat.value?.id === chatId) {
348
+ currentChat.value = chatHistories.value[chatIndex];
349
+ }
350
+ }
351
+ };
352
+
353
+ const setChatContextWindowTokens = (chatId: string, tokens: number) => {
354
+ const normalizedTokens = Number(tokens);
355
+ if (!Number.isFinite(normalizedTokens) || normalizedTokens < 0) {
356
+ return;
357
+ }
358
+
359
+ const chatIndex = chatHistories.value.findIndex(c => c.id === chatId);
360
+ if (chatIndex !== -1) {
361
+ const chat = chatHistories.value[chatIndex];
362
+ chat.contextWindowTokens = Math.max(0, Math.floor(normalizedTokens));
363
+
364
+ chatHistories.value = [...chatHistories.value];
365
+
366
+ if (currentChat.value?.id === chatId) {
367
+ currentChat.value = chatHistories.value[chatIndex];
368
+ }
369
+ }
370
+ };
371
+
372
+ const updateMessage = (
373
+ chatId: string,
374
+ messageId: string,
375
+ updates: Partial<SvedaDisplayMessage>
376
+ ) => {
377
+ const chatIndex = chatHistories.value.findIndex(c => c.id === chatId);
378
+ if (chatIndex !== -1) {
379
+ const chat = chatHistories.value[chatIndex];
380
+ const messageIndex = chat.messages.findIndex(m => m.id === messageId);
381
+ if (messageIndex !== -1) {
382
+ const updatedMessage = {
383
+ ...chat.messages[messageIndex],
384
+ ...updates,
385
+ };
386
+ chat.messages.splice(messageIndex, 1, updatedMessage);
387
+ chat.updatedAt = Date.now();
388
+
389
+ chatHistories.value = [...chatHistories.value];
390
+
391
+ if (currentChat.value?.id === chatId) {
392
+ currentChat.value = chatHistories.value[chatIndex];
393
+ }
394
+
395
+ return updatedMessage;
396
+ }
397
+ }
398
+ return null;
399
+ };
400
+
401
+ const setChatMessages = (chatId: string, messages: SvedaDisplayMessage[]) => {
402
+ const result = upsertChatHistoryMessages(
403
+ chatHistories.value,
404
+ currentChat.value,
405
+ chatId,
406
+ finalizeForDisplay(messages)
407
+ );
408
+
409
+ chatHistories.value = result.histories;
410
+ currentChat.value = result.current;
411
+ if (result.current?.id === chatId) {
412
+ chatState.currentChatId = chatId;
413
+ ensureChatTab(chatId);
414
+ }
415
+ };
416
+
417
+ const deleteChat = (chatId: string, translate?: (key: string) => string) => {
418
+ const index = chatHistories.value.findIndex(c => c.id === chatId);
419
+ if (index !== -1) {
420
+ chatHistories.value.splice(index, 1);
421
+ removeChatTab(chatId);
422
+ void deleteChatOnServer(chatId);
423
+
424
+ if (chatState.currentChatId === chatId) {
425
+ if (chatHistories.value.length > 0) {
426
+ const nextChat = chatHistories.value[0];
427
+ void setCurrentChat(nextChat.id, translate);
428
+ } else {
429
+ createNewChat(translate);
430
+ }
431
+ }
432
+ }
433
+ };
434
+
435
+ const renameChat = (chatId: string, title: string) => {
436
+ const normalizedTitle = title.trim();
437
+ if (!normalizedTitle) {
438
+ return;
439
+ }
440
+
441
+ setChatTitle(chatId, normalizedTitle);
442
+ void renameChatOnServer(chatId, normalizedTitle);
443
+ };
444
+
445
+ export const useSvedaChat = () => {
446
+ const client = inject(SvedaClientKey, null);
447
+ const t = useSvedaT();
448
+
449
+ if (client) {
450
+ activeClient = client;
451
+ }
452
+
453
+ if (!initialized) {
454
+ initialized = true;
455
+ if (historiesEndpointConfigured()) {
456
+ void loadHistories();
457
+ }
458
+ }
459
+
460
+ const isOpen = computed(() => chatState.isOpen);
461
+ const isMinimized = computed(() => chatState.isMinimized);
462
+ const isLoading = computed(() => chatState.isLoading);
463
+ const isLoadingChatHistory = computed(() => chatState.isLoadingChatHistory);
464
+ const hasCurrentChat = computed(() => !!currentChat.value);
465
+ const sortedHistories = computed(() => {
466
+ return [...chatHistories.value]
467
+ .filter(shouldIncludeInHistoryList)
468
+ .sort((a, b) => b.updatedAt - a.updatedAt);
469
+ });
470
+ const openChatTabs = computed(() => {
471
+ const ids = [...openChatTabIds.value];
472
+ if (currentChat.value?.id && !ids.includes(currentChat.value.id)) {
473
+ ids.push(currentChat.value.id);
474
+ }
475
+
476
+ return ids
477
+ .map(id => chatHistories.value.find(chat => chat.id === id))
478
+ .filter((chat): chat is SvedaChatHistory => !!chat);
479
+ });
480
+
481
+ const createNewChatWithI18n = (): string => {
482
+ return createNewChat(t);
483
+ };
484
+
485
+ const setCurrentChatWithI18n = async (chatId: string) => {
486
+ await setCurrentChat(chatId, t);
487
+ };
488
+
489
+ const closeChatTab = async (chatId: string) => {
490
+ const currentIndex = openChatTabIds.value.findIndex(id => id === chatId);
491
+ removeChatTab(chatId);
492
+
493
+ if (currentChat.value?.id !== chatId) {
494
+ return;
495
+ }
496
+
497
+ const nextChatId =
498
+ openChatTabIds.value[currentIndex] ||
499
+ openChatTabIds.value[currentIndex - 1] ||
500
+ sortedHistories.value.find(chat => chat.id !== chatId)?.id;
501
+
502
+ if (nextChatId) {
503
+ await setCurrentChatWithI18n(nextChatId);
504
+ return;
505
+ }
506
+
507
+ createNewChatWithI18n();
508
+ };
509
+
510
+ const openChat = async () => {
511
+ chatState.isOpen = true;
512
+ chatState.isMinimized = false;
513
+ writePersistedMinimized(false);
514
+ if (!currentChat.value && chatHistories.value.length === 0) {
515
+ createNewChatWithI18n();
516
+ } else if (!currentChat.value && chatHistories.value.length > 0) {
517
+ await setCurrentChatWithI18n(chatHistories.value[0].id);
518
+ }
519
+ };
520
+
521
+ const closeChat = () => {
522
+ chatState.isOpen = false;
523
+ chatState.isMinimized = true;
524
+ writePersistedMinimized(true);
525
+ };
526
+
527
+ const minimizeChat = () => {
528
+ chatState.isMinimized = true;
529
+ writePersistedMinimized(true);
530
+ };
531
+
532
+ const maximizeChat = () => {
533
+ chatState.isMinimized = false;
534
+ chatState.isOpen = true;
535
+ writePersistedMinimized(false);
536
+ };
537
+
538
+ const setLoading = (loading: boolean) => {
539
+ chatState.isLoading = loading;
540
+ };
541
+
542
+ const refreshChatTitleFromServer = async (chatId: string): Promise<string | null> => {
543
+ const loaded = await fetchChatHistoryFromServer(chatId);
544
+ if (!loaded) {
545
+ return null;
546
+ }
547
+
548
+ if (loaded.messages.length > 0) {
549
+ const current =
550
+ currentChat.value?.id === chatId
551
+ ? currentChat.value
552
+ : chatHistories.value.find(chat => chat.id === chatId);
553
+ const localCount = current?.messages.length ?? 0;
554
+ if (loaded.messages.length >= localCount) {
555
+ setChatMessages(chatId, loaded.messages);
556
+ }
557
+ }
558
+
559
+ const title = loaded.title?.trim();
560
+ return title || null;
561
+ };
562
+
563
+ return {
564
+ chatState: readonly(chatState),
565
+ currentChat,
566
+ chatHistories: readonly(chatHistories),
567
+ sortedHistories,
568
+ openChatTabs,
569
+ isOpen,
570
+ isMinimized,
571
+ isLoading,
572
+ isLoadingChatHistory,
573
+ hasCurrentChat,
574
+ loadHistories,
575
+ createNewChat: createNewChatWithI18n,
576
+ setCurrentChat: setCurrentChatWithI18n,
577
+ addMessage,
578
+ setChatTitle,
579
+ refreshChatTitleFromServer,
580
+ updateMessage,
581
+ setChatMessages,
582
+ incrementChatTokens,
583
+ setChatContextWindowTokens,
584
+ deleteChat: (chatId: string) => deleteChat(chatId, t),
585
+ renameChat: (chatId: string, title: string) => renameChat(chatId, title),
586
+ closeChatTab,
587
+ openChat,
588
+ closeChat,
589
+ minimizeChat,
590
+ maximizeChat,
591
+ setLoading,
592
+ };
593
+ };