research-agent-ui 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 (125) hide show
  1. package/README.md +177 -0
  2. package/dist/api/handlers/agents.d.ts +4 -0
  3. package/dist/api/handlers/article-followups.d.ts +2 -0
  4. package/dist/api/handlers/article-qa.d.ts +2 -0
  5. package/dist/api/handlers/autocomplete.d.ts +8 -0
  6. package/dist/api/handlers/chats.d.ts +23 -0
  7. package/dist/api/handlers/mcpservers.d.ts +24 -0
  8. package/dist/api/handlers/messages.d.ts +4 -0
  9. package/dist/api/handlers/providers.d.ts +29 -0
  10. package/dist/api/handlers/rewrite.d.ts +4 -0
  11. package/dist/api/handlers/search.d.ts +7 -0
  12. package/dist/api/handlers/suggestions.d.ts +3 -0
  13. package/dist/api/handlers/test-models.d.ts +3 -0
  14. package/dist/api/handlers/transcript.d.ts +4 -0
  15. package/dist/api/handlers/validate-openrouter.d.ts +5 -0
  16. package/dist/api/handlers/voice.d.ts +4 -0
  17. package/dist/api/index.d.ts +16 -0
  18. package/dist/api/types.d.ts +86 -0
  19. package/dist/api.cjs +22 -0
  20. package/dist/api.mjs +768 -0
  21. package/dist/components/ArticleReader/ArticleAIResponse.d.ts +11 -0
  22. package/dist/components/ArticleReader/ArticleActionButtons.d.ts +18 -0
  23. package/dist/components/ArticleReader/ArticleContent.d.ts +8 -0
  24. package/dist/components/ArticleReader/ArticleExtractPanel.d.ts +4 -0
  25. package/dist/components/ArticleReader/ArticleFollowupQuestions.d.ts +12 -0
  26. package/dist/components/ArticleReader/ArticlePanelHeader.d.ts +9 -0
  27. package/dist/components/ArticleReader/ArticlePromptInput.d.ts +11 -0
  28. package/dist/components/ArticleReader/ExtractPanelContext.d.ts +18 -0
  29. package/dist/components/ArticleReader/LexicalArticleViewer.d.ts +15 -0
  30. package/dist/components/ArticleReader/index.d.ts +12 -0
  31. package/dist/components/ArticleReader/unified-markdown.d.ts +19 -0
  32. package/dist/components/ChatConversation/ChatConversationThread.d.ts +10 -0
  33. package/dist/components/ChatConversation/ChatHeaderNavigationBar.d.ts +2 -0
  34. package/dist/components/ChatConversation/ChatHomepage.d.ts +6 -0
  35. package/dist/components/ChatConversation/ChatMessageBubble.d.ts +19 -0
  36. package/dist/components/ChatConversation/ChatMessageInputBar.d.ts +10 -0
  37. package/dist/components/ChatConversation/ChatWindow.d.ts +75 -0
  38. package/dist/components/ChatConversation/EmptyStateChatMessageInput.d.ts +9 -0
  39. package/dist/components/ChatConversation/MessageBubble/AssistantMessageActions.d.ts +15 -0
  40. package/dist/components/ChatConversation/MessageBubble/FollowUpSuggestions.d.ts +15 -0
  41. package/dist/components/ChatConversation/MessageBubble/ThinkTagProcessor.d.ts +13 -0
  42. package/dist/components/ChatConversation/MessageBubble/UserMessageHeader.d.ts +20 -0
  43. package/dist/components/ChatConversation/MessageReasoningPanel.d.ts +14 -0
  44. package/dist/components/ChatConversation/RecentHistoryChips.d.ts +1 -0
  45. package/dist/components/ChatConversation/SearchModeSpotlightPanel.d.ts +10 -0
  46. package/dist/components/ChatConversation/background-art.d.ts +11 -0
  47. package/dist/components/ChatHistoryDropdown/HistoryChatItem.d.ts +9 -0
  48. package/dist/components/ChatHistoryDropdown/HistoryDialogs.d.ts +14 -0
  49. package/dist/components/ChatHistoryDropdown/HistoryDropdown.d.ts +6 -0
  50. package/dist/components/ChatHistoryDropdown/HistoryHeader.d.ts +10 -0
  51. package/dist/components/ChatHistoryDropdown/index.d.ts +4 -0
  52. package/dist/components/ChatHistoryDropdown/useHistoryState.d.ts +27 -0
  53. package/dist/components/ConfigError.d.ts +1 -0
  54. package/dist/components/FileUpload/CompactFileAttachmentButton.d.ts +2 -0
  55. package/dist/components/FileUpload/FileAttachmentButton.d.ts +2 -0
  56. package/dist/components/FileUpload/FilePreviewCard.d.ts +13 -0
  57. package/dist/components/FileUpload/FileUploadDropdown.d.ts +7 -0
  58. package/dist/components/FileUpload/GoogleDrivePicker.d.ts +4 -0
  59. package/dist/components/FileUpload/useFileHandling.d.ts +26 -0
  60. package/dist/components/Footer.d.ts +19 -0
  61. package/dist/components/MessageActions/CopyMessageButton.d.ts +6 -0
  62. package/dist/components/MessageActions/DeleteChatSessionButton.d.ts +8 -0
  63. package/dist/components/MessageActions/RewriteMessageButton.d.ts +5 -0
  64. package/dist/components/MessageComposer/ActionBar.d.ts +17 -0
  65. package/dist/components/MessageComposer/ChatInputBox.d.ts +6 -0
  66. package/dist/components/MessageComposer/MessageInputIconSet.d.ts +24 -0
  67. package/dist/components/MessageComposer/PastedContentCard.d.ts +12 -0
  68. package/dist/components/SearchConfig/CategoriesMenu.d.ts +2 -0
  69. package/dist/components/SearchConfig/ChatModelSelector.d.ts +2 -0
  70. package/dist/components/SearchConfig/ModelSelector.d.ts +8 -0
  71. package/dist/components/SearchConfig/ModelSelectorSubmenu.d.ts +2 -0
  72. package/dist/components/SearchConfig/ResearchFocusToggleButton.d.ts +2 -0
  73. package/dist/components/SearchConfig/SearchOptimizationSelector.d.ts +2 -0
  74. package/dist/components/SearchConfig/categories.d.ts +10 -0
  75. package/dist/components/SearchResults/MessageSources.d.ts +11 -0
  76. package/dist/components/SearchResults/NewsArticleWidget.d.ts +2 -0
  77. package/dist/components/SearchResults/SearchProgressIndicator.d.ts +8 -0
  78. package/dist/components/SearchResults/WebCitationBadge.d.ts +7 -0
  79. package/dist/config.cjs +1 -0
  80. package/dist/config.d.ts +54 -0
  81. package/dist/config.mjs +16 -0
  82. package/dist/hooks/useChat/ChatContext.d.ts +147 -0
  83. package/dist/hooks/useChat/ChatProvider.d.ts +35 -0
  84. package/dist/hooks/useChat/buildSections.d.ts +39 -0
  85. package/dist/hooks/useChat/chatConfig.d.ts +31 -0
  86. package/dist/hooks/useChat/chatMessages.d.ts +48 -0
  87. package/dist/hooks/useChat/index.d.ts +58 -0
  88. package/dist/hooks/useChat/sendMessage.d.ts +91 -0
  89. package/dist/hooks/useChat/useChat.d.ts +3 -0
  90. package/dist/hooks/useChat/useChatState.d.ts +127 -0
  91. package/dist/hooks/useSession.d.ts +21 -0
  92. package/dist/hooks/voice/useInteruptionDetection.d.ts +16 -0
  93. package/dist/hooks/voice/useSpeechToTranscript.d.ts +5 -0
  94. package/dist/hooks/voice/useTextToVoice.d.ts +13 -0
  95. package/dist/icons/IconSearchAcademic.d.ts +1 -0
  96. package/dist/icons/IconSearchFiles.d.ts +1 -0
  97. package/dist/icons/IconSearchImages.d.ts +1 -0
  98. package/dist/icons/IconSearchNews.d.ts +1 -0
  99. package/dist/icons/IconSearchTech.d.ts +1 -0
  100. package/dist/icons/IconSearchVideos.d.ts +1 -0
  101. package/dist/icons/IconSearchWeb.d.ts +1 -0
  102. package/dist/index.cjs +52 -0
  103. package/dist/index.d.ts +14 -0
  104. package/dist/index.mjs +5847 -0
  105. package/dist/lib/cdn-loader.d.ts +2 -0
  106. package/dist/lib/export.d.ts +17 -0
  107. package/dist/lib/guest.d.ts +19 -0
  108. package/dist/lib/suggestions.d.ts +2 -0
  109. package/dist/lib/url-autolink.d.ts +21 -0
  110. package/dist/lib/utils.d.ts +3 -0
  111. package/dist/rolldown-runtime-CMqjfN_6.cjs +1 -0
  112. package/dist/types/chat.d.ts +132 -0
  113. package/dist/types/research.d.ts +81 -0
  114. package/dist/ui/Loader.d.ts +2 -0
  115. package/dist/ui/badge.d.ts +9 -0
  116. package/dist/ui/button.d.ts +11 -0
  117. package/dist/ui/dialog.d.ts +15 -0
  118. package/dist/ui/dropdown-menu.d.ts +25 -0
  119. package/dist/ui/glowing-effect.d.ts +14 -0
  120. package/dist/ui/gradient-blur.d.ts +9 -0
  121. package/dist/ui/live-waveform.d.ts +23 -0
  122. package/dist/ui/popover.d.ts +9 -0
  123. package/dist/ui/tooltip.d.ts +7 -0
  124. package/dist/ui/visually-hidden.d.ts +2 -0
  125. package/package.json +96 -0
@@ -0,0 +1,127 @@
1
+ /**
2
+ * @fileoverview React hook for managing all chat-related state.
3
+ * Centralizes useState, useRef, and useMemo hooks for the chat system,
4
+ * providing a clean separation between state management and side effects.
5
+ * @module components/ResearchAgent/state/chat/useChatState
6
+ */
7
+ import { ChatTurn, Message } from "../../components/ChatConversation/ChatWindow";
8
+ import { ChatFile, ChatModelProvider, Section } from "../../types/chat";
9
+ /**
10
+ * The complete state object for the chat system.
11
+ * Contains all values managed by useState hooks.
12
+ */
13
+ export interface ChatState {
14
+ /** Unique identifier for the current chat session */
15
+ chatId: string | undefined;
16
+ /** Whether this is a newly created chat (not loaded from storage) */
17
+ newChatCreated: boolean;
18
+ /** Whether a message is currently being sent/processed */
19
+ loading: boolean;
20
+ /** Whether the AI response has started appearing (for loading indicators) */
21
+ messageAppeared: boolean;
22
+ /** History of conversation as [role, content] pairs for context */
23
+ chatHistory: [string, string][];
24
+ /** All messages in the current chat */
25
+ messages: Message[];
26
+ /** Files attached to the chat */
27
+ files: ChatFile[];
28
+ /** IDs of attached files for API requests */
29
+ fileIds: string[];
30
+ /** Current search/focus mode (e.g., 'webSearch', 'academic') */
31
+ focusMode: string;
32
+ /** Current category for search filtering */
33
+ category: string;
34
+ /** Response optimization mode (e.g., 'speed', 'quality') */
35
+ optimizationMode: string;
36
+ /** Whether messages have been loaded from storage/API */
37
+ isMessagesLoaded: boolean;
38
+ /** Whether the requested chat was not found */
39
+ notFound: boolean;
40
+ /** Current AI model provider configuration */
41
+ chatModelProvider: ChatModelProvider;
42
+ /** Whether the model configuration has been loaded */
43
+ isConfigReady: boolean;
44
+ /** Whether an error occurred during initialization */
45
+ hasError: boolean;
46
+ /** Whether the chat system is fully ready for use */
47
+ isReady: boolean;
48
+ }
49
+ /**
50
+ * Collection of setter functions for updating chat state.
51
+ * Includes both simple setters and React dispatch functions for complex updates.
52
+ */
53
+ export interface ChatStateSetters {
54
+ /** Sets the chat ID */
55
+ setChatId: (id: string | undefined) => void;
56
+ /** Sets whether a new chat was created */
57
+ setNewChatCreated: (created: boolean) => void;
58
+ /** Sets the loading state */
59
+ setLoading: (loading: boolean) => void;
60
+ /** Sets whether the message has appeared */
61
+ setMessageAppeared: (appeared: boolean) => void;
62
+ /** Sets the chat history (supports functional updates) */
63
+ setChatHistory: React.Dispatch<React.SetStateAction<[string, string][]>>;
64
+ /** Sets the messages array (supports functional updates) */
65
+ setMessages: React.Dispatch<React.SetStateAction<Message[]>>;
66
+ /** Sets the attached files */
67
+ setFiles: (files: ChatFile[]) => void;
68
+ /** Sets the file IDs */
69
+ setFileIds: (ids: string[]) => void;
70
+ /** Sets the focus mode */
71
+ setFocusMode: (mode: string) => void;
72
+ /** Sets the category */
73
+ setCategory: (category: string) => void;
74
+ /** Sets the optimization mode */
75
+ setOptimizationMode: (mode: string) => void;
76
+ /** Sets whether messages are loaded */
77
+ setIsMessagesLoaded: (loaded: boolean) => void;
78
+ /** Sets the not found state */
79
+ setNotFound: (notFound: boolean) => void;
80
+ /** Sets the chat model provider */
81
+ setChatModelProvider: (provider: ChatModelProvider) => void;
82
+ /** Sets whether config is ready */
83
+ setIsConfigReady: (ready: boolean) => void;
84
+ /** Sets the error state */
85
+ setHasError: (hasError: boolean) => void;
86
+ /** Sets the ready state */
87
+ setIsReady: (ready: boolean) => void;
88
+ }
89
+ /**
90
+ * Return type of the useChatState hook.
91
+ */
92
+ export interface UseChatStateReturn {
93
+ /** All state values */
94
+ state: ChatState;
95
+ /** All setter functions */
96
+ setters: ChatStateSetters;
97
+ /** Ref to current messages (for use in async callbacks) */
98
+ messagesRef: React.MutableRefObject<Message[]>;
99
+ /** Filtered list of user and assistant messages only */
100
+ chatTurns: ChatTurn[];
101
+ /** Processed sections for UI rendering */
102
+ sections: Section[];
103
+ }
104
+ /**
105
+ * Custom hook that manages all state for the chat system.
106
+ *
107
+ * This hook centralizes all useState, useRef, and useMemo hooks used by the chat,
108
+ * providing a clean separation between state management and side effects.
109
+ * The ChatProvider uses this hook and adds useEffect hooks for side effects.
110
+ *
111
+ * @param initialChatId - Optional chat ID to initialize with (from URL params)
112
+ * @returns Object containing state, setters, ref, and derived values
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * function ChatProvider({ children }) {
117
+ * const { state, setters, messagesRef, chatTurns, sections } = useChatState(
118
+ * params.chatId
119
+ * );
120
+ *
121
+ * // Add effects using state and setters...
122
+ *
123
+ * return <ChatContext.Provider value={...}>{children}</ChatContext.Provider>;
124
+ * }
125
+ * ```
126
+ */
127
+ export declare function useChatState(initialChatId?: string): UseChatStateReturn;
@@ -0,0 +1,21 @@
1
+ import type { ResearchAgentAuthClient } from '../config';
2
+ interface User {
3
+ id: string;
4
+ name: string;
5
+ email?: string;
6
+ image?: string;
7
+ }
8
+ interface SessionContextType {
9
+ user: User | null;
10
+ isLoading: boolean;
11
+ isAuthenticated: boolean;
12
+ signIn: () => void;
13
+ signOut: () => Promise<void>;
14
+ }
15
+ export declare function SessionProvider({ children, authClient, }: {
16
+ children: React.ReactNode;
17
+ /** Configured better-auth (or compatible) client used to manage the session. */
18
+ authClient: ResearchAgentAuthClient;
19
+ }): import("react").JSX.Element;
20
+ export declare function useSession(): SessionContextType;
21
+ export {};
@@ -0,0 +1,16 @@
1
+ /**
2
+ * React hook combining Silero VAD (via @huggingface/transformers) with
3
+ * turn-done detection based on sustained silence after speech ends.
4
+ *
5
+ * Usage:
6
+ * const { isListening, isSpeaking, isTurnDone, lastSpeechSegment, start, stop }
7
+ * = useSileroSmartTurn();
8
+ */
9
+ export declare function useSileroSmartTurn(): {
10
+ isListening: boolean;
11
+ isSpeaking: boolean;
12
+ isTurnDone: boolean;
13
+ lastSpeechSegment: Float32Array<ArrayBufferLike>;
14
+ start: () => Promise<void>;
15
+ stop: () => void;
16
+ };
@@ -0,0 +1,5 @@
1
+ export declare function useSpeechInput(onTranscript: (transcript: string) => void, onEnd: () => void): {
2
+ isListening: boolean;
3
+ toggleSpeech: () => Promise<void>;
4
+ isSpeechSupported: boolean;
5
+ };
@@ -0,0 +1,13 @@
1
+ type SpeechStatus = "started" | "stopped";
2
+ interface TextToSpeechOptions {
3
+ /** Enable mic-based interruption detection while TTS is playing. Only activates if mic permission is already granted. */
4
+ enableInterrupt?: boolean;
5
+ /** Called with the captured speech audio (16kHz Float32Array) after the user interrupts and finishes speaking. */
6
+ onInterrupted?: (audio: Float32Array) => void;
7
+ }
8
+ export declare function useTextToSpeech(text: string, options?: TextToSpeechOptions): {
9
+ speechStatus: SpeechStatus;
10
+ start: () => Promise<void>;
11
+ stop: () => void;
12
+ };
13
+ export {};
@@ -0,0 +1 @@
1
+ export default function IconSearchAcademic(props: React.SVGProps<SVGSVGElement>): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ export default function IconSearchFiles(props: React.SVGProps<SVGSVGElement>): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ export default function IconSearchImages(props: React.SVGProps<SVGSVGElement>): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ export default function IconSearchNews(props: React.SVGProps<SVGSVGElement>): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ export default function IconSearchTech(props: React.SVGProps<SVGSVGElement>): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ export default function IconSearchVideos(props: React.SVGProps<SVGSVGElement>): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ export default function IconSearchWeb(props: React.SVGProps<SVGSVGElement>): import("react").JSX.Element;