@deinossrl/dgp-agent 1.4.4 → 1.4.6
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 +86 -30
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -390,12 +390,12 @@ Devuelve los comandos necesarios en formato JSON.`;
|
|
|
390
390
|
}
|
|
391
391
|
|
|
392
392
|
/**
|
|
393
|
-
* Modo
|
|
393
|
+
* Modo IA - Escucha tareas de la web y las ejecuta con Claude
|
|
394
394
|
*/
|
|
395
395
|
async function runAIMode() {
|
|
396
396
|
console.log('');
|
|
397
397
|
console.log(`${colors.cyan}╔═══════════════════════════════════════════════════════╗${colors.reset}`);
|
|
398
|
-
console.log(`${colors.cyan}║ DGP Agent - AI Mode 🤖
|
|
398
|
+
console.log(`${colors.cyan}║ DGP Agent - AI Mode v1.4.6 🤖 ║${colors.reset}`);
|
|
399
399
|
console.log(`${colors.cyan}║ Powered by Claude ║${colors.reset}`);
|
|
400
400
|
console.log(`${colors.cyan}╚═══════════════════════════════════════════════════════╝${colors.reset}`);
|
|
401
401
|
console.log('');
|
|
@@ -441,37 +441,91 @@ async function runAIMode() {
|
|
|
441
441
|
const taskArgs = process.argv.slice(3).join(' ');
|
|
442
442
|
|
|
443
443
|
if (taskArgs) {
|
|
444
|
-
// Ejecutar tarea pasada como argumento
|
|
444
|
+
// Ejecutar tarea pasada como argumento y salir
|
|
445
445
|
await executeAITask(taskArgs);
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
const readline = await import('readline');
|
|
449
|
-
const rl = readline.createInterface({
|
|
450
|
-
input: process.stdin,
|
|
451
|
-
output: process.stdout,
|
|
452
|
-
});
|
|
446
|
+
process.exit(0);
|
|
447
|
+
}
|
|
453
448
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
process.exit(0);
|
|
460
|
-
}
|
|
449
|
+
// Modo escucha: polling de tareas AI desde la plataforma
|
|
450
|
+
logInfo(`Escuchando tareas desde TenMinute IA... (machine: ${CONFIG.machineId})`);
|
|
451
|
+
log('Las tareas enviadas desde la web se ejecutarán automáticamente', 'gray');
|
|
452
|
+
log('Presiona Ctrl+C para salir', 'gray');
|
|
453
|
+
console.log('');
|
|
461
454
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
455
|
+
let isProcessing = false;
|
|
456
|
+
|
|
457
|
+
const pollAITasks = async () => {
|
|
458
|
+
if (isProcessing) return; // Evitar ejecuciones simultáneas
|
|
465
459
|
|
|
466
|
-
|
|
467
|
-
|
|
460
|
+
try {
|
|
461
|
+
// Buscar comandos pendientes para esta máquina
|
|
462
|
+
const url = `${CONFIG.commandsUrl}?machine_id=eq.${CONFIG.machineId}&status=eq.pending&command=eq.ai_task&select=*&order=created_at.asc&limit=1`;
|
|
463
|
+
const response = await fetch(url, {
|
|
464
|
+
headers: {
|
|
465
|
+
'apikey': CONFIG.supabaseKey,
|
|
466
|
+
'Authorization': `Bearer ${CONFIG.supabaseKey}`,
|
|
467
|
+
},
|
|
468
468
|
});
|
|
469
|
-
};
|
|
470
469
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
470
|
+
if (!response.ok) return;
|
|
471
|
+
|
|
472
|
+
const commands = await response.json();
|
|
473
|
+
if (commands.length === 0) return;
|
|
474
|
+
|
|
475
|
+
const command = commands[0];
|
|
476
|
+
isProcessing = true;
|
|
477
|
+
|
|
478
|
+
logAI(`📥 Tarea recibida: ${command.params?.task?.substring(0, 50)}...`);
|
|
479
|
+
|
|
480
|
+
// Marcar como running
|
|
481
|
+
await updateCommandStatus(command.id, 'running', {});
|
|
482
|
+
|
|
483
|
+
// Ejecutar la tarea con AI
|
|
484
|
+
const result = await executeAITask(command.params?.task || '');
|
|
485
|
+
|
|
486
|
+
// Reportar resultado
|
|
487
|
+
if (result.success) {
|
|
488
|
+
await updateCommandStatus(command.id, 'completed', {
|
|
489
|
+
output: result.results?.map(r => r.output).join('\n'),
|
|
490
|
+
commands_executed: result.results?.length || 0,
|
|
491
|
+
});
|
|
492
|
+
logSuccess('Tarea completada y reportada a la plataforma');
|
|
493
|
+
} else {
|
|
494
|
+
await updateCommandStatus(command.id, 'failed', {}, result.error || 'Task failed');
|
|
495
|
+
logError('Tarea fallida');
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
isProcessing = false;
|
|
499
|
+
console.log('');
|
|
500
|
+
logInfo('Esperando más tareas...');
|
|
501
|
+
|
|
502
|
+
} catch (error) {
|
|
503
|
+
isProcessing = false;
|
|
504
|
+
// Silent fail para no spamear logs
|
|
505
|
+
if (!error.message.includes('42P01')) {
|
|
506
|
+
// Solo loguear si no es error de tabla inexistente
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
|
|
511
|
+
// Poll inmediato
|
|
512
|
+
await pollAITasks();
|
|
513
|
+
|
|
514
|
+
// Polling cada N segundos
|
|
515
|
+
setInterval(pollAITasks, CONFIG.commandPollInterval * 1000);
|
|
516
|
+
|
|
517
|
+
// También reportar status periódicamente
|
|
518
|
+
const reportStatus = async () => {
|
|
519
|
+
try {
|
|
520
|
+
const status = getRepoStatus();
|
|
521
|
+
await sendStatus(status);
|
|
522
|
+
} catch (e) {
|
|
523
|
+
// Silent fail
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
|
|
527
|
+
await reportStatus();
|
|
528
|
+
setInterval(reportStatus, CONFIG.interval * 1000);
|
|
475
529
|
}
|
|
476
530
|
|
|
477
531
|
// ============================================
|
|
@@ -942,7 +996,7 @@ async function runAgent(deployMode = false) {
|
|
|
942
996
|
console.log('');
|
|
943
997
|
console.log(`${colors.green}╔═══════════════════════════════════════════════════════╗${colors.reset}`);
|
|
944
998
|
console.log(`${colors.green}║ DGP Agent - Despliegue-GPT Local Agent ║${colors.reset}`);
|
|
945
|
-
console.log(`${colors.green}║ @deinossrl/dgp-agent v1.4.
|
|
999
|
+
console.log(`${colors.green}║ @deinossrl/dgp-agent v1.4.6 ║${colors.reset}`);
|
|
946
1000
|
console.log(`${colors.green}╚═══════════════════════════════════════════════════════╝${colors.reset}`);
|
|
947
1001
|
console.log('');
|
|
948
1002
|
|
|
@@ -1058,7 +1112,7 @@ async function showStatus() {
|
|
|
1058
1112
|
function showHelp() {
|
|
1059
1113
|
console.log(`
|
|
1060
1114
|
${colors.bold}${colors.cyan}DGP Agent - Despliegue-GPT Local Agent${colors.reset}
|
|
1061
|
-
${colors.gray}@deinossrl/dgp-agent v1.4.
|
|
1115
|
+
${colors.gray}@deinossrl/dgp-agent v1.4.6${colors.reset}
|
|
1062
1116
|
|
|
1063
1117
|
${colors.bold}DESCRIPCIÓN${colors.reset}
|
|
1064
1118
|
Agente local que reporta el estado de tu repositorio Git
|
|
@@ -1109,6 +1163,8 @@ ${colors.bold}REQUISITOS PARA DEPLOY${colors.reset}
|
|
|
1109
1163
|
- Permisos sudo para reload nginx (vía sudoers sin password)
|
|
1110
1164
|
|
|
1111
1165
|
${colors.bold}CHANGELOG${colors.reset}
|
|
1166
|
+
${colors.cyan}v1.4.6${colors.reset} - Fix: versión en banner AI Mode
|
|
1167
|
+
${colors.cyan}v1.4.5${colors.reset} - Modo escucha: recibe tareas AI desde la web
|
|
1112
1168
|
${colors.cyan}v1.4.4${colors.reset} - Config global (compartida por todos los agentes)
|
|
1113
1169
|
${colors.cyan}v1.4.3${colors.reset} - Config desde plataforma web (TenMinute IA)
|
|
1114
1170
|
${colors.cyan}v1.4.2${colors.reset} - Fix: alineación banner, config persistente
|
|
@@ -1276,7 +1332,7 @@ switch (command) {
|
|
|
1276
1332
|
case 'version':
|
|
1277
1333
|
case '-v':
|
|
1278
1334
|
case '--version':
|
|
1279
|
-
console.log('@deinossrl/dgp-agent v1.4.
|
|
1335
|
+
console.log('@deinossrl/dgp-agent v1.4.6');
|
|
1280
1336
|
break;
|
|
1281
1337
|
case 'ai':
|
|
1282
1338
|
case '--ai':
|