File size: 2,010 Bytes
5350fe7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// Shared functionality
document.addEventListener('DOMContentLoaded', () => {
    // Initialize any shared components
    console.log('VAI platform initialized');
    
    // Example: API connection status monitoring
    setInterval(() => {
        const status = Math.random() > 0.1 ? 'Connected' : 'Connection Issues';
        const color = status === 'Connected' ? 'text-green-400' : 'text-yellow-400';
        const statusElement = document.getElementById('connection-status');
        if (statusElement) {
            statusElement.textContent = status;
            statusElement.className = `text-xs ${color}`;
        }
    }, 5000);
});

// Workspace agent management
class AgentManager {
    constructor() {
        this.agents = [];
        this.activeAgentId = null;
    }
    
    addAgent(config) {
        const agent = {
            id: Date.now().toString(),
            name: config.name || `Agent ${this.agents.length + 1}`,
            model: config.model || 'ChatGPT',
            status: 'waiting',
            history: []
        };
        this.agents.push(agent);
        return agent;
    }
    
    activateAgent(agentId) {
        this.activeAgentId = agentId;
        this.agents.forEach(agent => {
            agent.status = agent.id === agentId ? 'active' : 'waiting';
        });
    }
}

// Initialize agent manager if on workspace page
if (window.location.pathname.includes('workspace')) {
    window.agentManager = new AgentManager();
    
    // Add default agents
    window.agentManager.addAgent({ name: 'Research Agent', model: 'ChatGPT-4' });
    window.agentManager.addAgent({ name: 'Writing Agent', model: 'Claude-3' });
    window.agentManager.addAgent({ name: 'Analysis Agent', model: 'Lovable Agent' });
    window.agentManager.addAgent({ name: 'Execution Agent', model: 'GPT-4 Turbo' });
    
    // Activate first agent by default
    if (window.agentManager.agents.length > 0) {
        window.agentManager.activateAgent(window.agentManager.agents[0].id);
    }
}