Voice AI Features: - LiveKit Agents integration for real-time voice calls - Julia AI agent (Python) deployed to LiveKit Cloud - Token server for authentication - Debug screen with voice call testing - Voice call screen with full-screen UI Agent Configuration: - STT: Deepgram Nova-2 - LLM: OpenAI GPT-4o - TTS: Deepgram Aura Asteria (female voice) - Turn Detection: LiveKit Multilingual Model - VAD: Silero - Noise Cancellation: LiveKit BVC Files added: - julia-agent/ - Complete agent code and token server - app/voice-call.tsx - Full-screen voice call UI - services/livekitService.ts - LiveKit client service - contexts/VoiceTranscriptContext.tsx - Transcript state - polyfills/livekit-globals.ts - WebRTC polyfills 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
74 lines
2.5 KiB
TypeScript
74 lines
2.5 KiB
TypeScript
// CRITICAL: Import LiveKit globals FIRST before anything else!
|
|
// This must be the very first import to set up WebRTC globals
|
|
// before any LiveKit classes are loaded.
|
|
import '@/polyfills/livekit-globals';
|
|
|
|
import { useEffect } from 'react';
|
|
import { DarkTheme, DefaultTheme, ThemeProvider } from '@react-navigation/native';
|
|
import { Stack, router, useSegments } from 'expo-router';
|
|
import { StatusBar } from 'expo-status-bar';
|
|
import * as SplashScreen from 'expo-splash-screen';
|
|
import 'react-native-reanimated';
|
|
|
|
import { useColorScheme } from '@/hooks/use-color-scheme';
|
|
import { AuthProvider, useAuth } from '@/contexts/AuthContext';
|
|
import { BeneficiaryProvider } from '@/contexts/BeneficiaryContext';
|
|
import { VoiceTranscriptProvider } from '@/contexts/VoiceTranscriptContext';
|
|
import { LoadingSpinner } from '@/components/ui/LoadingSpinner';
|
|
|
|
// Prevent auto-hiding splash screen
|
|
SplashScreen.preventAutoHideAsync();
|
|
|
|
function RootLayoutNav() {
|
|
const colorScheme = useColorScheme();
|
|
const { isAuthenticated, isLoading } = useAuth();
|
|
const segments = useSegments();
|
|
|
|
useEffect(() => {
|
|
if (isLoading) return;
|
|
|
|
// Hide splash screen once we know auth state
|
|
SplashScreen.hideAsync();
|
|
|
|
const inAuthGroup = segments[0] === '(auth)';
|
|
|
|
if (!isAuthenticated && !inAuthGroup) {
|
|
// Redirect to login if not authenticated
|
|
router.replace('/(auth)/login');
|
|
} else if (isAuthenticated && inAuthGroup) {
|
|
// Redirect to main app if authenticated
|
|
router.replace('/(tabs)');
|
|
}
|
|
}, [isAuthenticated, isLoading, segments]);
|
|
|
|
if (isLoading) {
|
|
return <LoadingSpinner fullScreen message="Loading..." />;
|
|
}
|
|
|
|
return (
|
|
<ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
|
|
<Stack screenOptions={{ headerShown: false }}>
|
|
<Stack.Screen name="(auth)" />
|
|
<Stack.Screen name="(tabs)" />
|
|
<Stack.Screen name="modal" options={{ presentation: 'modal', title: 'Modal' }} />
|
|
<Stack.Screen name="voice-call" options={{ presentation: 'fullScreenModal', headerShown: false, gestureEnabled: false }} />
|
|
<Stack.Screen name="terms" options={{ presentation: 'modal' }} />
|
|
<Stack.Screen name="privacy" options={{ presentation: 'modal' }} />
|
|
</Stack>
|
|
<StatusBar style="auto" />
|
|
</ThemeProvider>
|
|
);
|
|
}
|
|
|
|
export default function RootLayout() {
|
|
return (
|
|
<AuthProvider>
|
|
<BeneficiaryProvider>
|
|
<VoiceTranscriptProvider>
|
|
<RootLayoutNav />
|
|
</VoiceTranscriptProvider>
|
|
</BeneficiaryProvider>
|
|
</AuthProvider>
|
|
);
|
|
}
|