@contentgrowth/llm-service 0.8.2 → 0.8.4

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.
@@ -0,0 +1,291 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import React, { RefObject, ReactNode } from 'react';
3
+
4
+ interface ChatBubbleProps {
5
+ onClick: () => void;
6
+ }
7
+ declare function ChatBubble({ onClick }: ChatBubbleProps): react_jsx_runtime.JSX.Element;
8
+
9
+ /**
10
+ * Types for interactive messages in the chat system
11
+ */
12
+ type InteractiveFunction = 'chat' | 'confirm' | 'select' | 'form' | 'present';
13
+ interface InteractiveMessage {
14
+ interactive: boolean;
15
+ function: InteractiveFunction;
16
+ parameters: Record<string, any>;
17
+ }
18
+ interface ChatInteractionParams {
19
+ prompt: string;
20
+ placeholder?: string;
21
+ }
22
+ interface ConfirmInteractionParams {
23
+ message: string;
24
+ yesPrompt: string;
25
+ noPrompt: string;
26
+ }
27
+ interface SelectInteractionParams {
28
+ question: string;
29
+ options: string[];
30
+ placeholder?: string;
31
+ }
32
+ interface FormField {
33
+ name: string;
34
+ label: string;
35
+ type: 'string' | 'number' | 'email' | 'textarea' | 'select' | 'checkbox' | 'radio' | 'password';
36
+ required?: boolean;
37
+ options?: string[];
38
+ placeholder?: string;
39
+ defaultValue?: any;
40
+ }
41
+ interface FormInteractionParams {
42
+ title: string;
43
+ label?: string;
44
+ description?: string;
45
+ fields: FormField[];
46
+ submitText?: string;
47
+ cancelText?: string;
48
+ }
49
+ interface PresentInteractionParams {
50
+ title?: string;
51
+ content: string;
52
+ level?: string;
53
+ format?: 'text' | 'markdown' | 'html';
54
+ }
55
+
56
+ /**
57
+ * Types related to chat functionality
58
+ */
59
+
60
+ /**
61
+ * ChatMessage represents a single message in the chat history
62
+ */
63
+ interface ChatMessage {
64
+ role: 'user' | 'assistant' | 'system' | 'error';
65
+ content: string;
66
+ id: string | number;
67
+ timestamp?: number;
68
+ interactive?: boolean;
69
+ request?: string;
70
+ interactiveData?: InteractiveMessage;
71
+ isResponseSubmitted?: boolean;
72
+ responseValue?: any;
73
+ rawContent?: string;
74
+ diff?: {
75
+ oldContent: string;
76
+ newContent: string;
77
+ };
78
+ actionResult?: {
79
+ type: 'link';
80
+ url: string;
81
+ label: string;
82
+ target?: string;
83
+ };
84
+ }
85
+ /**
86
+ * ChatTask represents a multi-step task being performed by the chat assistant
87
+ */
88
+ interface ChatTask {
89
+ complete: boolean;
90
+ steps: number;
91
+ currentStep: number;
92
+ }
93
+ /**
94
+ * Possible connection status values for the SSE connection
95
+ */
96
+ type ConnectionState = 'connected' | 'disconnected' | 'reconnecting';
97
+ /**
98
+ * Animation states for the chat UI
99
+ */
100
+ type AnimationState = 'closed' | 'opening' | 'open' | 'closing';
101
+ /**
102
+ * Custom EventSource interface that matches what chatApi.createChatStream returns
103
+ */
104
+ interface CustomEventSource {
105
+ close: () => void;
106
+ }
107
+ /**
108
+ * Result type returned by the connectToSSE function
109
+ * Contains the connectionId that can be used immediately without waiting for state updates
110
+ */
111
+ interface SSEConnectionResult {
112
+ connectionId: string | null;
113
+ }
114
+ /**
115
+ * Options for configuring the message submit handler
116
+ */
117
+ interface MessageSubmitOptions {
118
+ contextType: 'schedule' | 'tasks' | 'general';
119
+ enableNavigation?: boolean;
120
+ processNavigationIntent?: (text: string) => boolean;
121
+ handlePageSpecificCommand?: (text: string) => boolean;
122
+ }
123
+ /**
124
+ * Options for configuring the navigation handler
125
+ */
126
+ interface NavigationHandlerOptions {
127
+ onSwitchContext?: (contextType: 'schedule' | 'tasks' | 'general') => void;
128
+ onNavigationStart?: (action: string) => void;
129
+ onNavigationComplete?: () => void;
130
+ }
131
+ /**
132
+ * Options for configuring the chat trigger handler
133
+ */
134
+ interface ChatTriggerOptions {
135
+ contextType: 'schedule' | 'tasks' | 'general';
136
+ enabled?: boolean;
137
+ }
138
+ /**
139
+ * Configuration for voice input functionality
140
+ */
141
+ interface VoiceConfig {
142
+ mode: 'native' | 'custom';
143
+ onAudioCapture?: (blob: Blob) => Promise<string>;
144
+ onVoiceStart?: () => void;
145
+ onVoiceEnd?: () => void;
146
+ language?: string;
147
+ }
148
+
149
+ interface MessageBubbleProps {
150
+ message: ChatMessage;
151
+ isUser: boolean;
152
+ userAvatarUrl?: string;
153
+ onViewChanges?: (diff: {
154
+ oldContent: string;
155
+ newContent: string;
156
+ }) => void;
157
+ }
158
+ declare const MessageBubble: React.FC<MessageBubbleProps>;
159
+
160
+ interface ChatHeaderProps {
161
+ contextTitle: string;
162
+ currentTask: ChatTask | null;
163
+ onClose: () => void;
164
+ }
165
+ declare function ChatHeader({ contextTitle, currentTask, onClose }: ChatHeaderProps): react_jsx_runtime.JSX.Element;
166
+
167
+ interface ChatInputAreaProps {
168
+ onSubmit: (message: string) => void;
169
+ isSending: boolean;
170
+ showInputForm: boolean;
171
+ currentTask: ChatTask | null;
172
+ lastInteractiveMessage?: ChatMessage | null;
173
+ voiceConfig?: VoiceConfig;
174
+ onStop?: () => void;
175
+ hintText?: string;
176
+ placeholder?: string;
177
+ value?: string;
178
+ onChange?: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
179
+ }
180
+ interface ChatInputAreaHandle {
181
+ focus: () => void;
182
+ setValue: (value: string) => void;
183
+ }
184
+ declare const ChatInputArea: React.ForwardRefExoticComponent<ChatInputAreaProps & React.RefAttributes<ChatInputAreaHandle>>;
185
+
186
+ interface ChatMessageListProps {
187
+ chatHistory: ChatMessage[];
188
+ isProcessing: boolean;
189
+ processingHint: string;
190
+ currentTask: ChatTask | null;
191
+ getContextExample: () => string;
192
+ onInteractiveResponse?: (messageId: string | number, response: any) => void;
193
+ }
194
+ /**
195
+ * ChatMessageList component displays the chat messages and handles scrolling
196
+ * Features:
197
+ * - Displays user and system messages with different styling
198
+ * - Shows a typing indicator when the system is processing
199
+ * - Displays a welcome message when the chat is empty
200
+ * - Auto-scrolls to the bottom when new messages arrive
201
+ * - Handles interactive messages with different UI components
202
+ */
203
+ declare const ChatMessageList: React.FC<ChatMessageListProps>;
204
+
205
+ interface ConnectionStatusProps {
206
+ connectionStatus: 'connected' | 'disconnected' | 'reconnecting';
207
+ onReconnect: () => void;
208
+ }
209
+ declare const ConnectionStatus: React.FC<ConnectionStatusProps>;
210
+
211
+ interface SpinnerProps {
212
+ size?: 'sm' | 'md' | 'lg' | 'xl';
213
+ className?: string;
214
+ color?: string;
215
+ }
216
+ declare const Spinner: React.FC<SpinnerProps>;
217
+
218
+ /**
219
+ * A hook that proactively resizes a textarea based on the content of a hidden measurement element.
220
+ * This avoids the flickering often seen with standard "height: auto" approaches by measuring
221
+ * the content in a hidden span first, then applying the height to the textarea.
222
+ */
223
+ declare function useProactiveResize(textareaRef: RefObject<HTMLTextAreaElement>, measurementRef: RefObject<HTMLSpanElement>, value: string, disabled: boolean): void;
224
+
225
+ interface SpeechRecognitionHook {
226
+ isListening: boolean;
227
+ transcript: string;
228
+ start: () => void;
229
+ stop: () => void;
230
+ resetTranscript: () => void;
231
+ isSupported: boolean;
232
+ error: string | null;
233
+ }
234
+ declare const useSpeechRecognition: (onResult?: (text: string, isFinal: boolean) => void, onEnd?: () => void, language?: string) => SpeechRecognitionHook;
235
+
236
+ interface AudioRecorderHook {
237
+ isRecording: boolean;
238
+ start: () => Promise<void>;
239
+ stop: () => void;
240
+ blob: Blob | null;
241
+ error: string | null;
242
+ }
243
+ declare const useAudioRecorder: (onStop?: (blob: Blob) => void) => AudioRecorderHook;
244
+
245
+ interface ChatConfig {
246
+ user?: {
247
+ avatarUrl?: string;
248
+ name?: string;
249
+ };
250
+ voice?: {
251
+ enabled: boolean;
252
+ config?: VoiceConfig;
253
+ };
254
+ }
255
+ declare const ChatConfigProvider: React.FC<{
256
+ config: ChatConfig;
257
+ children: ReactNode;
258
+ }>;
259
+ declare const useChatConfig: () => ChatConfig;
260
+
261
+ /**
262
+ * Lightweight client for sending audio to a backend transcription endpoint.
263
+ * This keeps the API key secret on the server.
264
+ */
265
+ interface TranscriptionConfig {
266
+ endpoint: string;
267
+ language?: string;
268
+ headers?: Record<string, string>;
269
+ }
270
+ interface TranscriptionResult {
271
+ text: string;
272
+ error?: string;
273
+ }
274
+ /**
275
+ * Transcribe audio blob by sending it to the configured backend endpoint.
276
+ */
277
+ declare function transcribeAudio(audioBlob: Blob, config: TranscriptionConfig): Promise<string>;
278
+
279
+ /**
280
+ * Helper to create a VoiceConfig that uses the backend Whisper transcription service.
281
+ *
282
+ * @param config - Configuration for the transcription endpoint
283
+ * @param callbacks - Optional callbacks for voice events
284
+ * @returns VoiceConfig ready to be used in ChatInputArea
285
+ */
286
+ declare function createWhisperVoiceConfig(config: TranscriptionConfig, callbacks?: {
287
+ onVoiceStart?: () => void;
288
+ onVoiceEnd?: () => void;
289
+ }): VoiceConfig;
290
+
291
+ export { type AnimationState, type AudioRecorderHook, ChatBubble, type ChatConfig, ChatConfigProvider, ChatHeader, ChatInputArea, type ChatInputAreaHandle, type ChatInteractionParams, type ChatMessage, ChatMessageList, type ChatTask, type ChatTriggerOptions, type ConfirmInteractionParams, type ConnectionState, ConnectionStatus, type CustomEventSource, type FormField, type FormInteractionParams, type InteractiveFunction, type InteractiveMessage, MessageBubble, type MessageBubbleProps, type MessageSubmitOptions, type NavigationHandlerOptions, type PresentInteractionParams, type SSEConnectionResult, type SelectInteractionParams, type SpeechRecognitionHook, Spinner, type TranscriptionConfig, type TranscriptionResult, type VoiceConfig, createWhisperVoiceConfig, transcribeAudio, useAudioRecorder, useChatConfig, useProactiveResize, useSpeechRecognition };