File size: 2,095 Bytes
c216959
0491e54
 
c216959
0491e54
 
 
c6ad652
0491e54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c6ad652
0491e54
 
 
 
 
 
 
 
 
 
 
 
 
 
c216959
 
0491e54
 
 
c6ad652
 
0bdf0d8
c6ad652
 
0bdf0d8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""
FocusFlow: AI Accountability Agent with Gradio 5 Interface.
Configurable via environment variables for HuggingFace Spaces or local use.
"""
import gradio as gr
import os
from dotenv import load_dotenv
from shared import task_manager, metrics_tracker
from monitor import FileMonitor
from voice import voice_generator
from linear_client import LinearClient
from core.pomodoro import PomodoroTimer
from core.focus_check import FocusMonitor
from ui.handlers import UIHandlers
from ui.layout import create_app

# Load environment variables
load_dotenv()

# Import MCP tools to register them with Gradio
try:
    import mcp_tools
    MCP_AVAILABLE = True
except Exception as e:
    print(f"⚠️ MCP tools not available: {e}")
    MCP_AVAILABLE = False

# Configuration from environment
LAUNCH_MODE = os.getenv("LAUNCH_MODE", "demo").lower()  # 'demo' or 'local'
AI_PROVIDER = os.getenv("AI_PROVIDER", "openai").lower()  # 'openai', 'anthropic', or 'vllm'
MONITOR_INTERVAL = int(os.getenv("MONITOR_INTERVAL", "30"))  # seconds

# Initialize Core Components
# task_manager and metrics_tracker are imported from shared.py
file_monitor = FileMonitor()
linear_client = LinearClient()

# Initialize Logic Modules
focus_monitor = FocusMonitor(task_manager, file_monitor, metrics_tracker, voice_generator)
focus_monitor.set_launch_mode(LAUNCH_MODE)

pomodoro_timer = PomodoroTimer()

# Initialize UI Handlers
ui_handlers = UIHandlers(task_manager, file_monitor, metrics_tracker, focus_monitor, linear_client)

# Create App
app = create_app(ui_handlers, pomodoro_timer, LAUNCH_MODE, AI_PROVIDER, MONITOR_INTERVAL)

if __name__ == "__main__":
    # Enable MCP server if available
    mcp_enabled = os.getenv("ENABLE_MCP", "true").lower() == "true"

    if MCP_AVAILABLE and mcp_enabled:
        print("πŸ”— MCP Server enabled! Connect via Claude Desktop or other MCP clients.")
        app.launch(server_name="0.0.0.0", server_port=7860, share=False, mcp_server=True)
    else:
        print("πŸ“± Running without MCP integration")
        app.launch(server_name="0.0.0.0", server_port=7860, share=False)