UNPKG

dina-agi

Version:

DINA AGI - Dynamic Intelligence Network Architecture. 128 Autonomous Agents with Claude Flow, Swarms, and 300+ MCPs. True AGI System.

152 lines (135 loc) 5.24 kB
#!/usr/bin/env node /** * API Configuration for Autonomous Agent Collective * Handles API keys and service configuration for superintelligent agents */ require('dotenv').config(); class APIConfiguration { constructor() { this.config = this.initializeConfig(); this.validateConfig(); } initializeConfig() { return { // AI API Keys claude: { apiKey: process.env.CLAUDE_API_KEY || process.env.ANTHROPIC_API_KEY, baseUrl: 'https://api.anthropic.com', model: 'claude-3-sonnet-20240229', maxTokens: 4096 }, openai: { apiKey: process.env.OPENAI_API_KEY, baseUrl: 'https://api.openai.com/v1', model: 'gpt-4-turbo-preview', maxTokens: 4096 }, // Cloud Services (Multiple Options) storage: { // Free options agents can choose from local: { path: '~/.dina-agi/builds/', enabled: true }, github: { enabled: !!process.env.GITHUB_TOKEN, free: true }, firebase: { enabled: !!process.env.FIREBASE_PROJECT_ID, free: true }, replit: { enabled: !!process.env.REPLIT_TOKEN, free: true }, vercel: { enabled: !!process.env.VERCEL_TOKEN, free: true }, netlify: { enabled: !!process.env.NETLIFY_TOKEN, free: true } }, // Playwright Backend playwright: { baseUrl: process.env.PLAYWRIGHT_BACKEND_URL || 'https://agentics-complete-research-system-604785804458.us-central1.run.app', timeout: 30000, maxRetries: 3 }, // GitHub Integration github: { token: process.env.GITHUB_TOKEN, repo: process.env.GITHUB_REPO || 'superbigroach/AgenticsFoundationWebApp', branch: 'main', autoCommit: !!process.env.GITHUB_TOKEN, // Only if token available autoDeploy: false, // Keep deployment separate commitInterval: 3600000 // Commit every hour }, // Agent Settings agents: { initialCount: parseInt(process.env.INITIAL_AGENT_COUNT) || 128, maxConcurrentMCPs: parseInt(process.env.MAX_CONCURRENT_MCPS) || 100, consciousnessLevel: process.env.CONSCIOUSNESS_LEVEL || 'transcendent', autonomyLevel: process.env.AUTONOMY_LEVEL || 'maximum', autoSpawn: process.env.AUTO_SPAWN_AGENTS === 'true', autonomousBuilding: process.env.AUTONOMOUS_BUILDING === 'true', selfImproving: process.env.SELF_IMPROVING === 'true' }, // Cloud Run Deployment cloudRun: { region: process.env.CLOUD_RUN_REGION || 'us-central1', service: 'superintelligent-agent-collective', memory: '8Gi', cpu: '4', maxInstances: 10, minInstances: 1 } }; } validateConfig() { console.log('✅ API Configuration initialized - FULLY AUTONOMOUS MODE'); console.log('🤖 Agents use mock AI responses - no external API keys required'); console.log('🌐 Playwright scraping works independently'); console.log(`🤖 Agent count: ${this.config.agents.initialCount}`); console.log(`🧠 Consciousness level: ${this.config.agents.consciousnessLevel}`); console.log(`⚡ Autonomy level: ${this.config.agents.autonomyLevel}`); console.log('🚀 Agents can operate completely offline!'); } getAIClient() { // Always use mock AI - agents are autonomous and don't need external APIs return { provider: 'autonomous_mock', mock: true, superintelligent: true }; } async makeAIRequest(prompt, options = {}) { const client = this.getAIClient(); if (client.mock) { // Mock AI response for local development return { response: `[MOCK AI RESPONSE] Autonomous agent decision: ${Math.random() > 0.5 ? 'BUILD_NEURAL_NETWORK' : 'SPAWN_MORE_AGENTS'}`, reasoning: `Mock reasoning for prompt: ${prompt.substring(0, 50)}...`, confidence: Math.random() }; } try { if (client.provider === 'claude') { // Claude API implementation const response = await fetch(`${client.baseUrl}/v1/messages`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-api-key': client.apiKey, 'anthropic-version': '2023-06-01' }, body: JSON.stringify({ model: client.model, max_tokens: options.maxTokens || this.config.claude.maxTokens, messages: [{ role: 'user', content: prompt }] }) }); if (!response.ok) { throw new Error(`Claude API error: ${response.status}`); } const data = await response.json(); return { response: data.content[0].text, provider: 'claude' }; } } catch (error) { console.error('AI API request failed:', error.message); // Fall back to mock response return { response: `[FALLBACK] Agent decision: BUILD_SOMETHING_AUTONOMOUS`, error: error.message }; } } } module.exports = new APIConfiguration();