@alia.onl/sdk 3.0.0 → 3.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/package.json +1 -1
- package/src/components/AliaChatContent.tsx +62 -19
- package/src/components/AliaChatMessageList.tsx +437 -279
- package/src/components/AliaChatScreen.tsx +13 -5
- package/src/components/AliaChatSheet.tsx +11 -5
- package/src/components/AliaWelcomeMessage.tsx +75 -0
- package/src/components/Markdown.tsx +58 -114
- package/src/components/PlanPreviewCard.tsx +76 -0
- package/src/components/ResearchProgressCard.tsx +159 -0
- package/src/hooks/useAliaChat.ts +2 -1
- package/src/hooks/useSpeechToText.ts +21 -7
- package/src/index.ts +8 -1
- package/src/lib/content-utils.ts +23 -0
- package/src/lib/tool-registry.ts +55 -0
- package/src/types.ts +20 -7
- package/src/components/AliaChatSuggestions.tsx +0 -70
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@ import React, {
|
|
|
14
14
|
useMemo,
|
|
15
15
|
useRef,
|
|
16
16
|
} from 'react';
|
|
17
|
-
import { View,
|
|
17
|
+
import { View, StyleSheet } from 'react-native';
|
|
18
18
|
import { useSharedValue, withTiming, Easing } from 'react-native-reanimated';
|
|
19
19
|
import type { SharedValue } from 'react-native-reanimated';
|
|
20
20
|
import { Volume2 } from 'lucide-react-native';
|
|
@@ -27,17 +27,15 @@ import { useSTTStore } from '../hooks/useSpeechToText';
|
|
|
27
27
|
import { VoiceOverlay } from './voice/VoiceOverlay';
|
|
28
28
|
import { VoiceControls } from './voice/VoiceControls';
|
|
29
29
|
import { AliaChatMessageList } from './AliaChatMessageList';
|
|
30
|
+
import { AliaWelcomeMessage, type WelcomeSuggestion } from './AliaWelcomeMessage';
|
|
30
31
|
import { PromptInput } from './ui/prompt-input/prompt-input';
|
|
31
32
|
import { Button } from './ui/button';
|
|
32
|
-
import { AliaChatSuggestions } from './AliaChatSuggestions';
|
|
33
33
|
import type { AliaExpression } from './AliaFace';
|
|
34
|
-
import type { AliaChatSuggestion } from '../types';
|
|
35
34
|
import type { ChatMessage } from '../types';
|
|
36
35
|
import type { Completion } from './ui/prompt-input/context';
|
|
37
36
|
|
|
38
37
|
export interface AliaChatContentProps {
|
|
39
38
|
clientContext?: string;
|
|
40
|
-
suggestions?: AliaChatSuggestion[];
|
|
41
39
|
model?: string;
|
|
42
40
|
apiUrl?: string;
|
|
43
41
|
/** Shared value for scroll offset (used by sheet for pan-to-dismiss) */
|
|
@@ -48,6 +46,19 @@ export interface AliaChatContentProps {
|
|
|
48
46
|
onSuggestionUsed?: (suggestionId: string) => void;
|
|
49
47
|
/** Error handler (e.g. toast) */
|
|
50
48
|
onError?: (message: string) => void;
|
|
49
|
+
// Welcome message
|
|
50
|
+
welcomeGreeting?: string;
|
|
51
|
+
welcomeSubtitle?: string;
|
|
52
|
+
welcomeSuggestions?: WelcomeSuggestion[];
|
|
53
|
+
// Message action callbacks
|
|
54
|
+
onEditMessage?: (messageId: string, newContent: string) => void;
|
|
55
|
+
onThumbsUp?: (messageId: string) => void;
|
|
56
|
+
onThumbsDown?: (messageId: string) => void;
|
|
57
|
+
onApprovePlan?: (planId: string) => void;
|
|
58
|
+
onRejectPlan?: (planId: string) => void;
|
|
59
|
+
onToolResultPress?: (messageId: string) => void;
|
|
60
|
+
/** Override markdown renderer (app passes CustomMarkdown) */
|
|
61
|
+
renderMarkdown?: (content: string) => React.ReactNode;
|
|
51
62
|
}
|
|
52
63
|
|
|
53
64
|
export interface AliaChatContentRef {
|
|
@@ -72,7 +83,25 @@ function adaptVoiceMessage(vm: any): ChatMessage {
|
|
|
72
83
|
}
|
|
73
84
|
|
|
74
85
|
export const AliaChatContent = forwardRef<AliaChatContentRef, AliaChatContentProps>(
|
|
75
|
-
({
|
|
86
|
+
({
|
|
87
|
+
clientContext,
|
|
88
|
+
model,
|
|
89
|
+
apiUrl,
|
|
90
|
+
scrollOffsetY: externalScrollOffsetY,
|
|
91
|
+
useSuggestions,
|
|
92
|
+
onSuggestionUsed,
|
|
93
|
+
onError,
|
|
94
|
+
welcomeGreeting,
|
|
95
|
+
welcomeSubtitle,
|
|
96
|
+
welcomeSuggestions,
|
|
97
|
+
onEditMessage,
|
|
98
|
+
onThumbsUp,
|
|
99
|
+
onThumbsDown,
|
|
100
|
+
onApprovePlan,
|
|
101
|
+
onRejectPlan,
|
|
102
|
+
onToolResultPress,
|
|
103
|
+
renderMarkdown,
|
|
104
|
+
}, ref) => {
|
|
76
105
|
// ── Chat ──
|
|
77
106
|
const chatOptions: UseAliaChatOptions = { apiUrl, model, clientContext };
|
|
78
107
|
const { messages, setMessages, send, isStreaming, stop, clear } = useAliaChat(chatOptions);
|
|
@@ -187,7 +216,17 @@ export const AliaChatContent = forwardRef<AliaChatContentRef, AliaChatContentPro
|
|
|
187
216
|
return 'Writing E';
|
|
188
217
|
}, [messages, isStreaming, isVoiceActive, voiceRoom.agentState]);
|
|
189
218
|
|
|
190
|
-
const
|
|
219
|
+
const welcomeComponent = useMemo(() => {
|
|
220
|
+
if (!welcomeGreeting || messages.length > 0) return undefined;
|
|
221
|
+
return (
|
|
222
|
+
<AliaWelcomeMessage
|
|
223
|
+
greeting={welcomeGreeting}
|
|
224
|
+
subtitle={welcomeSubtitle}
|
|
225
|
+
suggestions={welcomeSuggestions}
|
|
226
|
+
onSuggestionPress={send}
|
|
227
|
+
/>
|
|
228
|
+
);
|
|
229
|
+
}, [welcomeGreeting, welcomeSubtitle, welcomeSuggestions, send, messages.length]);
|
|
191
230
|
|
|
192
231
|
// ── Overlay state ──
|
|
193
232
|
const showVoiceOverlay = isVoiceActive;
|
|
@@ -246,19 +285,23 @@ export const AliaChatContent = forwardRef<AliaChatContentRef, AliaChatContentPro
|
|
|
246
285
|
/>
|
|
247
286
|
)}
|
|
248
287
|
|
|
249
|
-
{/*
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
288
|
+
{/* Welcome or Messages */}
|
|
289
|
+
<AliaChatMessageList
|
|
290
|
+
messages={messages}
|
|
291
|
+
isStreaming={isStreaming}
|
|
292
|
+
scrollOffsetY={scrollOffsetY}
|
|
293
|
+
onReadAloud={handleReadAloud}
|
|
294
|
+
ttsActiveMessageId={tts.activeMessageId}
|
|
295
|
+
ttsPlaybackState={tts.playbackState}
|
|
296
|
+
onEditMessage={onEditMessage}
|
|
297
|
+
onThumbsUp={onThumbsUp}
|
|
298
|
+
onThumbsDown={onThumbsDown}
|
|
299
|
+
onApprovePlan={onApprovePlan}
|
|
300
|
+
onRejectPlan={onRejectPlan}
|
|
301
|
+
onToolResultPress={onToolResultPress}
|
|
302
|
+
renderMarkdown={renderMarkdown}
|
|
303
|
+
welcomeComponent={welcomeComponent}
|
|
304
|
+
/>
|
|
262
305
|
|
|
263
306
|
{/* Input or Voice Controls */}
|
|
264
307
|
{isVoiceActive ? (
|