@deinossrl/dgp-agent 1.4.9 → 1.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.mjs +26 -22
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -203,7 +203,7 @@ async function fetchPlatformConfig() {
|
|
|
203
203
|
let platformConfig = null;
|
|
204
204
|
|
|
205
205
|
// Versión y modo del agente
|
|
206
|
-
const AGENT_VERSION = '1.4.
|
|
206
|
+
const AGENT_VERSION = '1.4.10';
|
|
207
207
|
let AGENT_MODE = 'status'; // 'status' | 'deploy' | 'ai'
|
|
208
208
|
|
|
209
209
|
// Configuración (prioridad: env vars > archivo config > platform config > defaults)
|
|
@@ -559,8 +559,8 @@ async function runAIMode() {
|
|
|
559
559
|
if (isProcessing) return; // Evitar ejecuciones simultáneas
|
|
560
560
|
|
|
561
561
|
try {
|
|
562
|
-
// Buscar comandos pendientes para esta máquina
|
|
563
|
-
const url = `${CONFIG.commandsUrl}?machine_id=eq.${CONFIG.machineId}&status=eq.pending&
|
|
562
|
+
// Buscar TODOS los comandos pendientes para esta máquina (ai_task, git_commit_push, etc)
|
|
563
|
+
const url = `${CONFIG.commandsUrl}?machine_id=eq.${CONFIG.machineId}&status=eq.pending&select=*&order=created_at.asc&limit=1`;
|
|
564
564
|
const response = await fetch(url, {
|
|
565
565
|
headers: {
|
|
566
566
|
'apikey': CONFIG.supabaseKey,
|
|
@@ -576,35 +576,38 @@ async function runAIMode() {
|
|
|
576
576
|
const command = commands[0];
|
|
577
577
|
isProcessing = true;
|
|
578
578
|
|
|
579
|
-
|
|
579
|
+
// Manejar diferentes tipos de comandos
|
|
580
|
+
if (command.command === 'ai_task') {
|
|
581
|
+
logAI(`📥 Tarea AI recibida: ${command.params?.task?.substring(0, 50)}...`);
|
|
582
|
+
await updateCommandStatus(command.id, 'running', {});
|
|
580
583
|
|
|
581
|
-
|
|
582
|
-
await updateCommandStatus(command.id, 'running', {});
|
|
584
|
+
const result = await executeAITask(command.params?.task || '');
|
|
583
585
|
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
586
|
+
if (result.success) {
|
|
587
|
+
await updateCommandStatus(command.id, 'completed', {
|
|
588
|
+
output: result.results?.map(r => r.output).join('\n'),
|
|
589
|
+
commands_executed: result.results?.length || 0,
|
|
590
|
+
});
|
|
591
|
+
logSuccess('Tarea AI completada');
|
|
592
|
+
} else {
|
|
593
|
+
await updateCommandStatus(command.id, 'failed', {}, result.error || 'Task failed');
|
|
594
|
+
logError('Tarea AI fallida');
|
|
595
|
+
}
|
|
594
596
|
} else {
|
|
595
|
-
|
|
596
|
-
|
|
597
|
+
// Comandos git (git_commit_push, git_pull, git_fetch, etc)
|
|
598
|
+
logInfo(`📥 Comando recibido: ${command.command}`);
|
|
599
|
+
await executeCommand(command);
|
|
597
600
|
}
|
|
598
601
|
|
|
599
602
|
isProcessing = false;
|
|
600
603
|
console.log('');
|
|
601
|
-
logInfo('Esperando más
|
|
604
|
+
logInfo('Esperando más comandos...');
|
|
602
605
|
|
|
603
606
|
} catch (error) {
|
|
604
607
|
isProcessing = false;
|
|
605
|
-
//
|
|
606
|
-
if (!error.message.includes('42P01')) {
|
|
607
|
-
|
|
608
|
+
// Log error para debug
|
|
609
|
+
if (error.message && !error.message.includes('42P01')) {
|
|
610
|
+
console.error(`${colors.red}[Error polling]${colors.reset}`, error.message);
|
|
608
611
|
}
|
|
609
612
|
}
|
|
610
613
|
};
|
|
@@ -1269,6 +1272,7 @@ ${colors.bold}REQUISITOS PARA DEPLOY${colors.reset}
|
|
|
1269
1272
|
- Permisos sudo para reload nginx (vía sudoers sin password)
|
|
1270
1273
|
|
|
1271
1274
|
${colors.bold}CHANGELOG${colors.reset}
|
|
1275
|
+
${colors.cyan}v1.4.10${colors.reset} - AI Mode escucha todos los comandos (git + ai_task)
|
|
1272
1276
|
${colors.cyan}v1.4.9${colors.reset} - Fix: AI Mode no reportaba status a la plataforma
|
|
1273
1277
|
${colors.cyan}v1.4.8${colors.reset} - Banner dinámico con padding automático
|
|
1274
1278
|
${colors.cyan}v1.4.7${colors.reset} - Modo AI visible en web, auto-kill agente anterior
|