diff --git a/src/ai/index.ts b/src/ai/index.ts index 40ad537..facf371 100644 --- a/src/ai/index.ts +++ b/src/ai/index.ts @@ -9,23 +9,24 @@ export async function initAI(config: any, auth: any): Promise { const keyManager = auth.getKeyManager(); const keys = keyManager.loadKeys(); + // Utiliser la configuration unifiée pour les modèles const providerConfig: ProviderConfig = { openai: { apiKey: keys.openai || '', - model: config.ai.openai?.model || 'gpt-4o-mini', - baseUrl: config.ai.openai?.baseUrl + model: config.providers?.openai?.model || 'gpt-4o-mini', + baseUrl: config.providers?.openai?.base_url }, mistral: { apiKey: keys.mistral || '', - model: config.ai.mistral?.model || 'mistral-large-latest', - baseUrl: config.ai.mistral?.baseUrl + model: config.providers?.mistral?.model || 'mistral-large-latest', + baseUrl: config.providers?.mistral?.base_url }, defaultProvider: keys.openai ? 'openai' : 'mistral' }; - // Ajuster le provider par défaut selon les clés disponibles - if (config.ai.defaultProvider && keys[config.ai.defaultProvider as keyof typeof keys]) { - providerConfig.defaultProvider = config.ai.defaultProvider; + // Ajuster le provider par défaut selon la config et les clés disponibles + if (config.providers?.default && keys[config.providers.default as keyof typeof keys]) { + providerConfig.defaultProvider = config.providers.default; } return new AIClient(providerConfig); diff --git a/src/commands/index.ts b/src/commands/index.ts index 748763e..9091baa 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -15,23 +15,31 @@ export class CommandProcessor { constructor( private config: any, private dependencies: { - terminal: Terminal; + terminal: any; // Peut être Terminal ou ModernInterface auth: any; ai: AIClient; codebase: any; fileOps: any; execution: any; errors: any; + engine?: any; + memory?: any; + identity?: any; } ) { this.taskPlanner = new TaskPlanner( this.dependencies.ai, this.dependencies.execution.getCommandExecutor() ); + // Utiliser le prompt de la nouvelle interface si disponible + const prompt = this.dependencies.terminal.getPrompt ? + this.dependencies.terminal.getPrompt() : + '🧠 NeuraTerm> '; + this.rl = readline.createInterface({ input: process.stdin, output: process.stdout, - prompt: '🧠 NeuraTerm> ' + prompt }); } @@ -49,7 +57,12 @@ export class CommandProcessor { try { await this.processCommand(command); } catch (error) { - this.dependencies.terminal.displayError(error instanceof Error ? error.message : String(error)); + // Support des deux types d'interface + if (this.dependencies.terminal.displayError) { + this.dependencies.terminal.displayError(error instanceof Error ? error.message : String(error)); + } else { + console.error(`❌ Erreur: ${error instanceof Error ? error.message : String(error)}`); + } logger.error('Erreur lors du traitement de la commande:', error); } @@ -62,6 +75,44 @@ export class CommandProcessor { }); } + /** + * Helper pour supporter les deux types d'interface + */ + private displayMessage(type: 'error' | 'success' | 'info' | 'warning', message: string): void { + const terminal = this.dependencies.terminal; + + switch (type) { + case 'error': + if (terminal.displayError) { + terminal.displayError(message); + } else { + console.error(`❌ Erreur: ${message}`); + } + break; + case 'success': + if (terminal.displaySuccess) { + terminal.displaySuccess(message); + } else { + console.log(`✅ ${message}`); + } + break; + case 'info': + if (terminal.displayInfo) { + terminal.displayInfo(message); + } else { + console.log(`💡 ${message}`); + } + break; + case 'warning': + if (terminal.displayWarning) { + terminal.displayWarning(message); + } else { + console.log(`⚠️ ${message}`); + } + break; + } + } + private async processCommand(command: string): Promise { const [cmd, ...args] = command.split(' '); diff --git a/src/index.ts b/src/index.ts index de0fe04..f973717 100644 --- a/src/index.ts +++ b/src/index.ts @@ -129,8 +129,9 @@ export async function run(app: AppInstance): Promise { // Présentation de l'identité NeuraTerm console.log(app.identity.generateIntroduction()); - // Authentification si nécessaire + // Authentification des clés API si nécessaire if (!app.auth.isAuthenticated()) { + console.log('\n🔑 Configuration des clés API requise...'); await app.auth.authenticate(); }