@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.
- package/LICENSE +21 -0
- package/README.md +9 -0
- package/dist/appearance.d.ts +52 -0
- package/dist/appearance.d.ts.map +1 -0
- package/dist/components/chat/AnimatedStreamBlock.vue.d.ts +16 -0
- package/dist/components/chat/AnimatedStreamBlock.vue.d.ts.map +1 -0
- package/dist/components/chat/ChatHistoryDropdown.vue.d.ts +17 -0
- package/dist/components/chat/ChatHistoryDropdown.vue.d.ts.map +1 -0
- package/dist/components/chat/ChatInput.vue.d.ts +30 -0
- package/dist/components/chat/ChatInput.vue.d.ts.map +1 -0
- package/dist/components/chat/ChatMessageActivityBlock.vue.d.ts +13 -0
- package/dist/components/chat/ChatMessageActivityBlock.vue.d.ts.map +1 -0
- package/dist/components/chat/ChatMessageItem.vue.d.ts +15 -0
- package/dist/components/chat/ChatMessageItem.vue.d.ts.map +1 -0
- package/dist/components/chat/ChatMessageList.vue.d.ts +31 -0
- package/dist/components/chat/ChatMessageList.vue.d.ts.map +1 -0
- package/dist/components/chat/ChatPendingIndicator.vue.d.ts +12 -0
- package/dist/components/chat/ChatPendingIndicator.vue.d.ts.map +1 -0
- package/dist/components/chat/ReasoningStream.vue.d.ts +11 -0
- package/dist/components/chat/ReasoningStream.vue.d.ts.map +1 -0
- package/dist/components/chat/index.d.ts +9 -0
- package/dist/components/chat/index.d.ts.map +1 -0
- package/dist/components/shell/SvedaAgentCompletedNotice.vue.d.ts +9 -0
- package/dist/components/shell/SvedaAgentCompletedNotice.vue.d.ts.map +1 -0
- package/dist/components/shell/SvedaAgentTasksPanel.vue.d.ts +12 -0
- package/dist/components/shell/SvedaAgentTasksPanel.vue.d.ts.map +1 -0
- package/dist/components/shell/SvedaChat.vue.d.ts +22 -0
- package/dist/components/shell/SvedaChat.vue.d.ts.map +1 -0
- package/dist/components/shell/SvedaContextUsageBar.vue.d.ts +10 -0
- package/dist/components/shell/SvedaContextUsageBar.vue.d.ts.map +1 -0
- package/dist/components/shell/SvedaHistorySheet.vue.d.ts +15 -0
- package/dist/components/shell/SvedaHistorySheet.vue.d.ts.map +1 -0
- package/dist/components/shell/SvedaHistorySidebar.vue.d.ts +15 -0
- package/dist/components/shell/SvedaHistorySidebar.vue.d.ts.map +1 -0
- package/dist/components/shell/SvedaInputSection.vue.d.ts +25 -0
- package/dist/components/shell/SvedaInputSection.vue.d.ts.map +1 -0
- package/dist/components/shell/SvedaLandingView.vue.d.ts +40 -0
- package/dist/components/shell/SvedaLandingView.vue.d.ts.map +1 -0
- package/dist/components/shell/SvedaMaxStepsNotice.vue.d.ts +13 -0
- package/dist/components/shell/SvedaMaxStepsNotice.vue.d.ts.map +1 -0
- package/dist/components/shell/SvedaMinimizedTrigger.vue.d.ts +15 -0
- package/dist/components/shell/SvedaMinimizedTrigger.vue.d.ts.map +1 -0
- package/dist/components/shell/SvedaModelControls.vue.d.ts +12 -0
- package/dist/components/shell/SvedaModelControls.vue.d.ts.map +1 -0
- package/dist/components/shell/SvedaModelSelect.vue.d.ts +10 -0
- package/dist/components/shell/SvedaModelSelect.vue.d.ts.map +1 -0
- package/dist/components/shell/SvedaQuickPrompts.vue.d.ts +13 -0
- package/dist/components/shell/SvedaQuickPrompts.vue.d.ts.map +1 -0
- package/dist/components/shell/SvedaResizeHandles.vue.d.ts +11 -0
- package/dist/components/shell/SvedaResizeHandles.vue.d.ts.map +1 -0
- package/dist/components/shell/SvedaTabs.vue.d.ts +17 -0
- package/dist/components/shell/SvedaTabs.vue.d.ts.map +1 -0
- package/dist/components/shell/SvedaToolbar.vue.d.ts +33 -0
- package/dist/components/shell/SvedaToolbar.vue.d.ts.map +1 -0
- package/dist/composables/useSvedaAgentTasks.d.ts +57 -0
- package/dist/composables/useSvedaAgentTasks.d.ts.map +1 -0
- package/dist/composables/useSvedaBootstrap.d.ts +18 -0
- package/dist/composables/useSvedaBootstrap.d.ts.map +1 -0
- package/dist/composables/useSvedaChat.d.ts +264 -0
- package/dist/composables/useSvedaChat.d.ts.map +1 -0
- package/dist/composables/useSvedaChatLayout.d.ts +39 -0
- package/dist/composables/useSvedaChatLayout.d.ts.map +1 -0
- package/dist/composables/useSvedaChatPage.d.ts +309 -0
- package/dist/composables/useSvedaChatPage.d.ts.map +1 -0
- package/dist/composables/useSvedaContextWindow.d.ts +10 -0
- package/dist/composables/useSvedaContextWindow.d.ts.map +1 -0
- package/dist/composables/useSvedaDocuments.d.ts +20 -0
- package/dist/composables/useSvedaDocuments.d.ts.map +1 -0
- package/dist/composables/useSvedaMaxStepsContinue.d.ts +12 -0
- package/dist/composables/useSvedaMaxStepsContinue.d.ts.map +1 -0
- package/dist/composables/useSvedaMessaging.d.ts +55 -0
- package/dist/composables/useSvedaMessaging.d.ts.map +1 -0
- package/dist/composables/useSvedaModel.d.ts +16 -0
- package/dist/composables/useSvedaModel.d.ts.map +1 -0
- package/dist/composables/useSvedaPrompts.d.ts +18 -0
- package/dist/composables/useSvedaPrompts.d.ts.map +1 -0
- package/dist/composables/useSvedaReadable.d.ts +3 -0
- package/dist/composables/useSvedaReadable.d.ts.map +1 -0
- package/dist/composables/useSvedaScroll.d.ts +19 -0
- package/dist/composables/useSvedaScroll.d.ts.map +1 -0
- package/dist/composables/useSvedaShell.d.ts +29 -0
- package/dist/composables/useSvedaShell.d.ts.map +1 -0
- package/dist/composables/useSvedaStreaming.d.ts +46 -0
- package/dist/composables/useSvedaStreaming.d.ts.map +1 -0
- package/dist/composables/useSvedaTool.d.ts +4 -0
- package/dist/composables/useSvedaTool.d.ts.map +1 -0
- package/dist/i18n/index.d.ts +18 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/locales/en.d.ts +4 -0
- package/dist/i18n/locales/en.d.ts.map +1 -0
- package/dist/i18n/locales/ru.d.ts +4 -0
- package/dist/i18n/locales/ru.d.ts.map +1 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6612 -0
- package/dist/launcherIcons.d.ts +5 -0
- package/dist/launcherIcons.d.ts.map +1 -0
- package/dist/lib/assistantMessage.d.ts +89 -0
- package/dist/lib/assistantMessage.d.ts.map +1 -0
- package/dist/lib/chatHistoryMerge.d.ts +20 -0
- package/dist/lib/chatHistoryMerge.d.ts.map +1 -0
- package/dist/lib/chatI18nKeys.d.ts +2 -0
- package/dist/lib/chatI18nKeys.d.ts.map +1 -0
- package/dist/lib/chatMessageVisibility.d.ts +4 -0
- package/dist/lib/chatMessageVisibility.d.ts.map +1 -0
- package/dist/lib/chatTabs.d.ts +9 -0
- package/dist/lib/chatTabs.d.ts.map +1 -0
- package/dist/lib/chatTitle.d.ts +3 -0
- package/dist/lib/chatTitle.d.ts.map +1 -0
- package/dist/lib/chatUiStorage.d.ts +4 -0
- package/dist/lib/chatUiStorage.d.ts.map +1 -0
- package/dist/lib/finalizeMessages.d.ts +21 -0
- package/dist/lib/finalizeMessages.d.ts.map +1 -0
- package/dist/lib/markdown.d.ts +8 -0
- package/dist/lib/markdown.d.ts.map +1 -0
- package/dist/lib/modelLabels.d.ts +3 -0
- package/dist/lib/modelLabels.d.ts.map +1 -0
- package/dist/lib/pendingStatusRotation.d.ts +3 -0
- package/dist/lib/pendingStatusRotation.d.ts.map +1 -0
- package/dist/lib/useAnimatedText.d.ts +8 -0
- package/dist/lib/useAnimatedText.d.ts.map +1 -0
- package/dist/lib/userMessage.d.ts +17 -0
- package/dist/lib/userMessage.d.ts.map +1 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/plugin.d.ts +64 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/styles.css +5 -0
- package/dist/ui/alert-dialog/AlertDialog.vue.d.ts +18 -0
- package/dist/ui/alert-dialog/AlertDialog.vue.d.ts.map +1 -0
- package/dist/ui/alert-dialog/AlertDialogAction.vue.d.ts +18 -0
- package/dist/ui/alert-dialog/AlertDialogAction.vue.d.ts.map +1 -0
- package/dist/ui/alert-dialog/AlertDialogCancel.vue.d.ts +18 -0
- package/dist/ui/alert-dialog/AlertDialogCancel.vue.d.ts.map +1 -0
- package/dist/ui/alert-dialog/AlertDialogContent.vue.d.ts +32 -0
- package/dist/ui/alert-dialog/AlertDialogContent.vue.d.ts.map +1 -0
- package/dist/ui/alert-dialog/AlertDialogDescription.vue.d.ts +18 -0
- package/dist/ui/alert-dialog/AlertDialogDescription.vue.d.ts.map +1 -0
- package/dist/ui/alert-dialog/AlertDialogFooter.vue.d.ts +17 -0
- package/dist/ui/alert-dialog/AlertDialogFooter.vue.d.ts.map +1 -0
- package/dist/ui/alert-dialog/AlertDialogHeader.vue.d.ts +17 -0
- package/dist/ui/alert-dialog/AlertDialogHeader.vue.d.ts.map +1 -0
- package/dist/ui/alert-dialog/AlertDialogTitle.vue.d.ts +18 -0
- package/dist/ui/alert-dialog/AlertDialogTitle.vue.d.ts.map +1 -0
- package/dist/ui/alert-dialog/AlertDialogTrigger.vue.d.ts +14 -0
- package/dist/ui/alert-dialog/AlertDialogTrigger.vue.d.ts.map +1 -0
- package/dist/ui/alert-dialog/index.d.ts +10 -0
- package/dist/ui/alert-dialog/index.d.ts.map +1 -0
- package/dist/ui/badge/Badge.vue.d.ts +19 -0
- package/dist/ui/badge/Badge.vue.d.ts.map +1 -0
- package/dist/ui/badge/index.d.ts +7 -0
- package/dist/ui/badge/index.d.ts.map +1 -0
- package/dist/ui/button/Button.vue.d.ts +23 -0
- package/dist/ui/button/Button.vue.d.ts.map +1 -0
- package/dist/ui/button/index.d.ts +9 -0
- package/dist/ui/button/index.d.ts.map +1 -0
- package/dist/ui/card/Card.vue.d.ts +17 -0
- package/dist/ui/card/Card.vue.d.ts.map +1 -0
- package/dist/ui/card/CardContent.vue.d.ts +17 -0
- package/dist/ui/card/CardContent.vue.d.ts.map +1 -0
- package/dist/ui/card/CardDescription.vue.d.ts +17 -0
- package/dist/ui/card/CardDescription.vue.d.ts.map +1 -0
- package/dist/ui/card/CardFooter.vue.d.ts +17 -0
- package/dist/ui/card/CardFooter.vue.d.ts.map +1 -0
- package/dist/ui/card/CardHeader.vue.d.ts +17 -0
- package/dist/ui/card/CardHeader.vue.d.ts.map +1 -0
- package/dist/ui/card/CardTitle.vue.d.ts +17 -0
- package/dist/ui/card/CardTitle.vue.d.ts.map +1 -0
- package/dist/ui/card/index.d.ts +7 -0
- package/dist/ui/card/index.d.ts.map +1 -0
- package/dist/ui/checkbox/Checkbox.vue.d.ts +30 -0
- package/dist/ui/checkbox/Checkbox.vue.d.ts.map +1 -0
- package/dist/ui/checkbox/index.d.ts +2 -0
- package/dist/ui/checkbox/index.d.ts.map +1 -0
- package/dist/ui/dialog/Dialog.vue.d.ts +18 -0
- package/dist/ui/dialog/Dialog.vue.d.ts.map +1 -0
- package/dist/ui/dialog/DialogClose.vue.d.ts +14 -0
- package/dist/ui/dialog/DialogClose.vue.d.ts.map +1 -0
- package/dist/ui/dialog/DialogContent.vue.d.ts +32 -0
- package/dist/ui/dialog/DialogContent.vue.d.ts.map +1 -0
- package/dist/ui/dialog/DialogDescription.vue.d.ts +18 -0
- package/dist/ui/dialog/DialogDescription.vue.d.ts.map +1 -0
- package/dist/ui/dialog/DialogFooter.vue.d.ts +17 -0
- package/dist/ui/dialog/DialogFooter.vue.d.ts.map +1 -0
- package/dist/ui/dialog/DialogHeader.vue.d.ts +17 -0
- package/dist/ui/dialog/DialogHeader.vue.d.ts.map +1 -0
- package/dist/ui/dialog/DialogScrollContent.vue.d.ts +32 -0
- package/dist/ui/dialog/DialogScrollContent.vue.d.ts.map +1 -0
- package/dist/ui/dialog/DialogTitle.vue.d.ts +18 -0
- package/dist/ui/dialog/DialogTitle.vue.d.ts.map +1 -0
- package/dist/ui/dialog/DialogTrigger.vue.d.ts +14 -0
- package/dist/ui/dialog/DialogTrigger.vue.d.ts.map +1 -0
- package/dist/ui/dialog/index.d.ts +10 -0
- package/dist/ui/dialog/index.d.ts.map +1 -0
- package/dist/ui/dropdown-menu/DropdownMenu.vue.d.ts +18 -0
- package/dist/ui/dropdown-menu/DropdownMenu.vue.d.ts.map +1 -0
- package/dist/ui/dropdown-menu/DropdownMenuCheckboxItem.vue.d.ts +24 -0
- package/dist/ui/dropdown-menu/DropdownMenuCheckboxItem.vue.d.ts.map +1 -0
- package/dist/ui/dropdown-menu/DropdownMenuContent.vue.d.ts +32 -0
- package/dist/ui/dropdown-menu/DropdownMenuContent.vue.d.ts.map +1 -0
- package/dist/ui/dropdown-menu/DropdownMenuGroup.vue.d.ts +14 -0
- package/dist/ui/dropdown-menu/DropdownMenuGroup.vue.d.ts.map +1 -0
- package/dist/ui/dropdown-menu/DropdownMenuItem.vue.d.ts +19 -0
- package/dist/ui/dropdown-menu/DropdownMenuItem.vue.d.ts.map +1 -0
- package/dist/ui/dropdown-menu/DropdownMenuLabel.vue.d.ts +19 -0
- package/dist/ui/dropdown-menu/DropdownMenuLabel.vue.d.ts.map +1 -0
- package/dist/ui/dropdown-menu/DropdownMenuRadioGroup.vue.d.ts +18 -0
- package/dist/ui/dropdown-menu/DropdownMenuRadioGroup.vue.d.ts.map +1 -0
- package/dist/ui/dropdown-menu/DropdownMenuRadioItem.vue.d.ts +22 -0
- package/dist/ui/dropdown-menu/DropdownMenuRadioItem.vue.d.ts.map +1 -0
- package/dist/ui/dropdown-menu/DropdownMenuSeparator.vue.d.ts +8 -0
- package/dist/ui/dropdown-menu/DropdownMenuSeparator.vue.d.ts.map +1 -0
- package/dist/ui/dropdown-menu/DropdownMenuShortcut.vue.d.ts +17 -0
- package/dist/ui/dropdown-menu/DropdownMenuShortcut.vue.d.ts.map +1 -0
- package/dist/ui/dropdown-menu/DropdownMenuSub.vue.d.ts +18 -0
- package/dist/ui/dropdown-menu/DropdownMenuSub.vue.d.ts.map +1 -0
- package/dist/ui/dropdown-menu/DropdownMenuSubContent.vue.d.ts +34 -0
- package/dist/ui/dropdown-menu/DropdownMenuSubContent.vue.d.ts.map +1 -0
- package/dist/ui/dropdown-menu/DropdownMenuSubTrigger.vue.d.ts +18 -0
- package/dist/ui/dropdown-menu/DropdownMenuSubTrigger.vue.d.ts.map +1 -0
- package/dist/ui/dropdown-menu/DropdownMenuTrigger.vue.d.ts +14 -0
- package/dist/ui/dropdown-menu/DropdownMenuTrigger.vue.d.ts.map +1 -0
- package/dist/ui/dropdown-menu/index.d.ts +16 -0
- package/dist/ui/dropdown-menu/index.d.ts.map +1 -0
- package/dist/ui/input/Input.vue.d.ts +13 -0
- package/dist/ui/input/Input.vue.d.ts.map +1 -0
- package/dist/ui/input/index.d.ts +2 -0
- package/dist/ui/input/index.d.ts.map +1 -0
- package/dist/ui/label/Label.vue.d.ts +18 -0
- package/dist/ui/label/Label.vue.d.ts.map +1 -0
- package/dist/ui/label/index.d.ts +2 -0
- package/dist/ui/label/index.d.ts.map +1 -0
- package/dist/ui/responsive-dialog/ResponsiveDialog.vue.d.ts +32 -0
- package/dist/ui/responsive-dialog/ResponsiveDialog.vue.d.ts.map +1 -0
- package/dist/ui/responsive-dialog/index.d.ts +2 -0
- package/dist/ui/responsive-dialog/index.d.ts.map +1 -0
- package/dist/ui/scroll-area/ScrollArea.vue.d.ts +18 -0
- package/dist/ui/scroll-area/ScrollArea.vue.d.ts.map +1 -0
- package/dist/ui/scroll-area/ScrollBar.vue.d.ts +10 -0
- package/dist/ui/scroll-area/ScrollBar.vue.d.ts.map +1 -0
- package/dist/ui/scroll-area/index.d.ts +3 -0
- package/dist/ui/scroll-area/index.d.ts.map +1 -0
- package/dist/ui/select/Select.vue.d.ts +21 -0
- package/dist/ui/select/Select.vue.d.ts.map +1 -0
- package/dist/ui/select/SelectContent.vue.d.ts +28 -0
- package/dist/ui/select/SelectContent.vue.d.ts.map +1 -0
- package/dist/ui/select/SelectGroup.vue.d.ts +18 -0
- package/dist/ui/select/SelectGroup.vue.d.ts.map +1 -0
- package/dist/ui/select/SelectItem.vue.d.ts +18 -0
- package/dist/ui/select/SelectItem.vue.d.ts.map +1 -0
- package/dist/ui/select/SelectItemText.vue.d.ts +14 -0
- package/dist/ui/select/SelectItemText.vue.d.ts.map +1 -0
- package/dist/ui/select/SelectLabel.vue.d.ts +18 -0
- package/dist/ui/select/SelectLabel.vue.d.ts.map +1 -0
- package/dist/ui/select/SelectScrollDownButton.vue.d.ts +18 -0
- package/dist/ui/select/SelectScrollDownButton.vue.d.ts.map +1 -0
- package/dist/ui/select/SelectScrollUpButton.vue.d.ts +18 -0
- package/dist/ui/select/SelectScrollUpButton.vue.d.ts.map +1 -0
- package/dist/ui/select/SelectSeparator.vue.d.ts +8 -0
- package/dist/ui/select/SelectSeparator.vue.d.ts.map +1 -0
- package/dist/ui/select/SelectTrigger.vue.d.ts +18 -0
- package/dist/ui/select/SelectTrigger.vue.d.ts.map +1 -0
- package/dist/ui/select/SelectValue.vue.d.ts +14 -0
- package/dist/ui/select/SelectValue.vue.d.ts.map +1 -0
- package/dist/ui/select/index.d.ts +12 -0
- package/dist/ui/select/index.d.ts.map +1 -0
- package/dist/ui/sheet/Sheet.vue.d.ts +18 -0
- package/dist/ui/sheet/Sheet.vue.d.ts.map +1 -0
- package/dist/ui/sheet/SheetClose.vue.d.ts +14 -0
- package/dist/ui/sheet/SheetClose.vue.d.ts.map +1 -0
- package/dist/ui/sheet/SheetContent.vue.d.ts +34 -0
- package/dist/ui/sheet/SheetContent.vue.d.ts.map +1 -0
- package/dist/ui/sheet/SheetDescription.vue.d.ts +18 -0
- package/dist/ui/sheet/SheetDescription.vue.d.ts.map +1 -0
- package/dist/ui/sheet/SheetFooter.vue.d.ts +17 -0
- package/dist/ui/sheet/SheetFooter.vue.d.ts.map +1 -0
- package/dist/ui/sheet/SheetHeader.vue.d.ts +17 -0
- package/dist/ui/sheet/SheetHeader.vue.d.ts.map +1 -0
- package/dist/ui/sheet/SheetTitle.vue.d.ts +18 -0
- package/dist/ui/sheet/SheetTitle.vue.d.ts.map +1 -0
- package/dist/ui/sheet/SheetTrigger.vue.d.ts +14 -0
- package/dist/ui/sheet/SheetTrigger.vue.d.ts.map +1 -0
- package/dist/ui/sheet/index.d.ts +14 -0
- package/dist/ui/sheet/index.d.ts.map +1 -0
- package/dist/ui/switch/Switch.vue.d.ts +23 -0
- package/dist/ui/switch/Switch.vue.d.ts.map +1 -0
- package/dist/ui/switch/index.d.ts +2 -0
- package/dist/ui/switch/index.d.ts.map +1 -0
- package/dist/ui/textarea/Textarea.vue.d.ts +13 -0
- package/dist/ui/textarea/Textarea.vue.d.ts.map +1 -0
- package/dist/ui/textarea/index.d.ts +2 -0
- package/dist/ui/textarea/index.d.ts.map +1 -0
- package/dist/ui/toast/Toast.vue.d.ts +96 -0
- package/dist/ui/toast/Toast.vue.d.ts.map +1 -0
- package/dist/ui/toast/ToastAction.vue.d.ts +18 -0
- package/dist/ui/toast/ToastAction.vue.d.ts.map +1 -0
- package/dist/ui/toast/ToastClose.vue.d.ts +8 -0
- package/dist/ui/toast/ToastClose.vue.d.ts.map +1 -0
- package/dist/ui/toast/ToastDescription.vue.d.ts +18 -0
- package/dist/ui/toast/ToastDescription.vue.d.ts.map +1 -0
- package/dist/ui/toast/ToastProvider.vue.d.ts +14 -0
- package/dist/ui/toast/ToastProvider.vue.d.ts.map +1 -0
- package/dist/ui/toast/ToastTitle.vue.d.ts +18 -0
- package/dist/ui/toast/ToastTitle.vue.d.ts.map +1 -0
- package/dist/ui/toast/ToastViewport.vue.d.ts +8 -0
- package/dist/ui/toast/ToastViewport.vue.d.ts.map +1 -0
- package/dist/ui/toast/Toaster.vue.d.ts +3 -0
- package/dist/ui/toast/Toaster.vue.d.ts.map +1 -0
- package/dist/ui/toast/index.d.ts +23 -0
- package/dist/ui/toast/index.d.ts.map +1 -0
- package/dist/ui/toast/use-toast.d.ts +23 -0
- package/dist/ui/toast/use-toast.d.ts.map +1 -0
- package/dist/ui/tooltip/Tooltip.vue.d.ts +18 -0
- package/dist/ui/tooltip/Tooltip.vue.d.ts.map +1 -0
- package/dist/ui/tooltip/TooltipContent.vue.d.ts +26 -0
- package/dist/ui/tooltip/TooltipContent.vue.d.ts.map +1 -0
- package/dist/ui/tooltip/TooltipProvider.vue.d.ts +14 -0
- package/dist/ui/tooltip/TooltipProvider.vue.d.ts.map +1 -0
- package/dist/ui/tooltip/TooltipTrigger.vue.d.ts +14 -0
- package/dist/ui/tooltip/TooltipTrigger.vue.d.ts.map +1 -0
- package/dist/ui/tooltip/index.d.ts +5 -0
- package/dist/ui/tooltip/index.d.ts.map +1 -0
- package/dist/ui/utils.d.ts +2 -0
- package/dist/ui/utils.d.ts.map +1 -0
- package/dist/vue.css +1 -0
- package/package.json +64 -0
- package/src/appearance.ts +568 -0
- package/src/components/chat/AnimatedStreamBlock.vue +94 -0
- package/src/components/chat/ChatHistoryDropdown.vue +226 -0
- package/src/components/chat/ChatInput.vue +571 -0
- package/src/components/chat/ChatMessageActivityBlock.vue +447 -0
- package/src/components/chat/ChatMessageItem.vue +357 -0
- package/src/components/chat/ChatMessageList.vue +178 -0
- package/src/components/chat/ChatPendingIndicator.vue +163 -0
- package/src/components/chat/ReasoningStream.vue +112 -0
- package/src/components/chat/index.ts +8 -0
- package/src/components/shell/SvedaAgentCompletedNotice.vue +25 -0
- package/src/components/shell/SvedaAgentTasksPanel.vue +146 -0
- package/src/components/shell/SvedaChat.vue +514 -0
- package/src/components/shell/SvedaContextUsageBar.vue +33 -0
- package/src/components/shell/SvedaHistorySheet.vue +52 -0
- package/src/components/shell/SvedaHistorySidebar.vue +41 -0
- package/src/components/shell/SvedaInputSection.vue +53 -0
- package/src/components/shell/SvedaLandingView.vue +93 -0
- package/src/components/shell/SvedaMaxStepsNotice.vue +33 -0
- package/src/components/shell/SvedaMinimizedTrigger.vue +43 -0
- package/src/components/shell/SvedaModelControls.vue +47 -0
- package/src/components/shell/SvedaModelSelect.vue +32 -0
- package/src/components/shell/SvedaQuickPrompts.vue +44 -0
- package/src/components/shell/SvedaResizeHandles.vue +31 -0
- package/src/components/shell/SvedaTabs.vue +123 -0
- package/src/components/shell/SvedaToolbar.vue +171 -0
- package/src/composables/useSvedaAgentTasks.ts +93 -0
- package/src/composables/useSvedaBootstrap.ts +36 -0
- package/src/composables/useSvedaChat.ts +593 -0
- package/src/composables/useSvedaChatLayout.ts +539 -0
- package/src/composables/useSvedaChatPage.ts +339 -0
- package/src/composables/useSvedaContextWindow.ts +31 -0
- package/src/composables/useSvedaDocuments.ts +115 -0
- package/src/composables/useSvedaMaxStepsContinue.ts +68 -0
- package/src/composables/useSvedaMessaging.ts +99 -0
- package/src/composables/useSvedaModel.ts +85 -0
- package/src/composables/useSvedaPrompts.ts +59 -0
- package/src/composables/useSvedaReadable.ts +33 -0
- package/src/composables/useSvedaScroll.ts +93 -0
- package/src/composables/useSvedaShell.ts +91 -0
- package/src/composables/useSvedaStreaming.ts +408 -0
- package/src/composables/useSvedaTool.ts +18 -0
- package/src/i18n/index.ts +72 -0
- package/src/i18n/locales/en.ts +58 -0
- package/src/i18n/locales/ru.ts +59 -0
- package/src/index.ts +141 -0
- package/src/launcherIcons.ts +39 -0
- package/src/lib/assistantMessage.ts +437 -0
- package/src/lib/chatHistoryMerge.ts +93 -0
- package/src/lib/chatI18nKeys.ts +62 -0
- package/src/lib/chatMessageVisibility.ts +50 -0
- package/src/lib/chatTabs.ts +54 -0
- package/src/lib/chatTitle.ts +30 -0
- package/src/lib/chatUiStorage.ts +33 -0
- package/src/lib/finalizeMessages.ts +81 -0
- package/src/lib/markdown.ts +90 -0
- package/src/lib/modelLabels.ts +24 -0
- package/src/lib/pendingStatusRotation.ts +26 -0
- package/src/lib/shims-vue.d.ts +6 -0
- package/src/lib/useAnimatedText.ts +78 -0
- package/src/lib/userMessage.ts +55 -0
- package/src/lib/utils.ts +6 -0
- package/src/plugin.ts +164 -0
- package/src/styles.css +5 -0
- package/src/theme.css +95 -0
- package/src/theme.test.mjs +80 -0
- package/src/ui/alert-dialog/AlertDialog.vue +14 -0
- package/src/ui/alert-dialog/AlertDialogAction.vue +17 -0
- package/src/ui/alert-dialog/AlertDialogCancel.vue +24 -0
- package/src/ui/alert-dialog/AlertDialogContent.vue +39 -0
- package/src/ui/alert-dialog/AlertDialogDescription.vue +22 -0
- package/src/ui/alert-dialog/AlertDialogFooter.vue +21 -0
- package/src/ui/alert-dialog/AlertDialogHeader.vue +16 -0
- package/src/ui/alert-dialog/AlertDialogTitle.vue +19 -0
- package/src/ui/alert-dialog/AlertDialogTrigger.vue +11 -0
- package/src/ui/alert-dialog/index.ts +9 -0
- package/src/ui/badge/Badge.vue +16 -0
- package/src/ui/badge/index.ts +27 -0
- package/src/ui/button/Button.vue +56 -0
- package/src/ui/button/index.ts +50 -0
- package/src/ui/card/Card.vue +14 -0
- package/src/ui/card/CardContent.vue +14 -0
- package/src/ui/card/CardDescription.vue +14 -0
- package/src/ui/card/CardFooter.vue +14 -0
- package/src/ui/card/CardHeader.vue +14 -0
- package/src/ui/card/CardTitle.vue +14 -0
- package/src/ui/card/index.ts +6 -0
- package/src/ui/checkbox/Checkbox.vue +41 -0
- package/src/ui/checkbox/index.ts +1 -0
- package/src/ui/dialog/Dialog.vue +14 -0
- package/src/ui/dialog/DialogClose.vue +11 -0
- package/src/ui/dialog/DialogContent.vue +50 -0
- package/src/ui/dialog/DialogDescription.vue +24 -0
- package/src/ui/dialog/DialogFooter.vue +19 -0
- package/src/ui/dialog/DialogHeader.vue +16 -0
- package/src/ui/dialog/DialogScrollContent.vue +59 -0
- package/src/ui/dialog/DialogTitle.vue +29 -0
- package/src/ui/dialog/DialogTrigger.vue +11 -0
- package/src/ui/dialog/index.ts +9 -0
- package/src/ui/dropdown-menu/DropdownMenu.vue +14 -0
- package/src/ui/dropdown-menu/DropdownMenuCheckboxItem.vue +42 -0
- package/src/ui/dropdown-menu/DropdownMenuContent.vue +40 -0
- package/src/ui/dropdown-menu/DropdownMenuGroup.vue +11 -0
- package/src/ui/dropdown-menu/DropdownMenuItem.vue +30 -0
- package/src/ui/dropdown-menu/DropdownMenuLabel.vue +21 -0
- package/src/ui/dropdown-menu/DropdownMenuRadioGroup.vue +14 -0
- package/src/ui/dropdown-menu/DropdownMenuRadioItem.vue +43 -0
- package/src/ui/dropdown-menu/DropdownMenuSeparator.vue +21 -0
- package/src/ui/dropdown-menu/DropdownMenuShortcut.vue +14 -0
- package/src/ui/dropdown-menu/DropdownMenuSub.vue +14 -0
- package/src/ui/dropdown-menu/DropdownMenuSubContent.vue +30 -0
- package/src/ui/dropdown-menu/DropdownMenuSubTrigger.vue +31 -0
- package/src/ui/dropdown-menu/DropdownMenuTrigger.vue +13 -0
- package/src/ui/dropdown-menu/index.ts +16 -0
- package/src/ui/input/Input.vue +32 -0
- package/src/ui/input/index.ts +1 -0
- package/src/ui/label/Label.vue +22 -0
- package/src/ui/label/index.ts +1 -0
- package/src/ui/responsive-dialog/ResponsiveDialog.vue +55 -0
- package/src/ui/responsive-dialog/index.ts +1 -0
- package/src/ui/scroll-area/ScrollArea.vue +29 -0
- package/src/ui/scroll-area/ScrollBar.vue +30 -0
- package/src/ui/scroll-area/index.ts +2 -0
- package/src/ui/select/Select.vue +15 -0
- package/src/ui/select/SelectContent.vue +53 -0
- package/src/ui/select/SelectGroup.vue +19 -0
- package/src/ui/select/SelectItem.vue +44 -0
- package/src/ui/select/SelectItemText.vue +11 -0
- package/src/ui/select/SelectLabel.vue +13 -0
- package/src/ui/select/SelectScrollDownButton.vue +24 -0
- package/src/ui/select/SelectScrollUpButton.vue +24 -0
- package/src/ui/select/SelectSeparator.vue +17 -0
- package/src/ui/select/SelectTrigger.vue +31 -0
- package/src/ui/select/SelectValue.vue +11 -0
- package/src/ui/select/index.ts +11 -0
- package/src/ui/sheet/Sheet.vue +14 -0
- package/src/ui/sheet/SheetClose.vue +11 -0
- package/src/ui/sheet/SheetContent.vue +53 -0
- package/src/ui/sheet/SheetDescription.vue +19 -0
- package/src/ui/sheet/SheetFooter.vue +12 -0
- package/src/ui/sheet/SheetHeader.vue +12 -0
- package/src/ui/sheet/SheetTitle.vue +19 -0
- package/src/ui/sheet/SheetTrigger.vue +11 -0
- package/src/ui/sheet/index.ts +29 -0
- package/src/ui/switch/Switch.vue +55 -0
- package/src/ui/switch/index.ts +1 -0
- package/src/ui/textarea/Textarea.vue +24 -0
- package/src/ui/textarea/index.ts +1 -0
- package/src/ui/toast/Toast.vue +28 -0
- package/src/ui/toast/ToastAction.vue +19 -0
- package/src/ui/toast/ToastClose.vue +22 -0
- package/src/ui/toast/ToastDescription.vue +19 -0
- package/src/ui/toast/ToastProvider.vue +11 -0
- package/src/ui/toast/ToastTitle.vue +19 -0
- package/src/ui/toast/ToastViewport.vue +17 -0
- package/src/ui/toast/Toaster.vue +48 -0
- package/src/ui/toast/index.ts +39 -0
- package/src/ui/toast/use-toast.ts +109 -0
- package/src/ui/tooltip/Tooltip.vue +14 -0
- package/src/ui/tooltip/TooltipContent.vue +39 -0
- package/src/ui/tooltip/TooltipProvider.vue +11 -0
- package/src/ui/tooltip/TooltipTrigger.vue +11 -0
- package/src/ui/tooltip/index.ts +4 -0
- 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
|
+
};
|