@deinossrl/dgp-agent 1.1.0 → 1.2.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.
Files changed (2) hide show
  1. package/index.mjs +66 -3
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -236,15 +236,20 @@ async function reportStatus(status) {
236
236
  const payload = {
237
237
  machine_id: CONFIG.machineId,
238
238
  timestamp: new Date().toISOString(),
239
+ agent_version: '1.2.5',
239
240
  status,
240
241
  };
241
242
 
242
243
  const headers = {
243
244
  'Content-Type': 'application/json',
245
+ 'apikey': CONFIG.supabaseKey,
244
246
  };
245
247
 
248
+ // Usar auth token del usuario si existe, sino usar el anon key
246
249
  if (CONFIG.authToken) {
247
250
  headers['Authorization'] = `Bearer ${CONFIG.authToken}`;
251
+ } else {
252
+ headers['Authorization'] = `Bearer ${CONFIG.supabaseKey}`;
248
253
  }
249
254
 
250
255
  const response = await fetch(CONFIG.apiUrl, {
@@ -438,6 +443,9 @@ async function executeCommand(command) {
438
443
  await updateCommandStatus(command.id, 'success', { status });
439
444
  return { success: true, status };
440
445
 
446
+ case 'git_commit_push':
447
+ return await executeGitCommitPush(command);
448
+
441
449
  case 'rollback':
442
450
  logError('Rollback not implemented yet');
443
451
  await updateCommandStatus(command.id, 'failed', {}, 'Rollback not implemented');
@@ -450,6 +458,53 @@ async function executeCommand(command) {
450
458
  }
451
459
  }
452
460
 
461
+ /**
462
+ * Ejecuta git add, commit y push
463
+ */
464
+ async function executeGitCommitPush(command) {
465
+ const { message, add_all } = command.params || {};
466
+
467
+ if (!message) {
468
+ await updateCommandStatus(command.id, 'failed', {}, 'Commit message is required');
469
+ return { success: false };
470
+ }
471
+
472
+ try {
473
+ // Marcar como running
474
+ await updateCommandStatus(command.id, 'running', {});
475
+
476
+ logInfo('Executing git commit + push...');
477
+
478
+ // git add
479
+ if (add_all) {
480
+ logCommand('git add .');
481
+ await shellAsync('git add .');
482
+ }
483
+
484
+ // git commit
485
+ logCommand(`git commit -m "${message}"`);
486
+ const commitResult = await shellAsync(`git commit -m "${message}"`);
487
+ logSuccess('Commit created');
488
+
489
+ // git push
490
+ const branch = shellSync('git branch --show-current').trim();
491
+ logCommand(`git push origin ${branch}`);
492
+ await shellAsync(`git push origin ${branch}`);
493
+ logSuccess('Push completed');
494
+
495
+ await updateCommandStatus(command.id, 'completed', {
496
+ commit: commitResult,
497
+ branch: branch
498
+ });
499
+
500
+ return { success: true };
501
+ } catch (error) {
502
+ logError(`Git commit/push failed: ${error.message}`);
503
+ await updateCommandStatus(command.id, 'failed', {}, error.message);
504
+ return { success: false, error: error.message };
505
+ }
506
+ }
507
+
453
508
  /**
454
509
  * Muestra el estado en consola
455
510
  */
@@ -483,7 +538,7 @@ async function runAgent(deployMode = false) {
483
538
  console.log('');
484
539
  console.log(`${colors.green}╔═══════════════════════════════════════════════════════╗${colors.reset}`);
485
540
  console.log(`${colors.green}║ DGP Agent - Despliegue-GPT Local Agent ║${colors.reset}`);
486
- console.log(`${colors.green}║ @deinossrl/dgp-agent v1.1.0 ║${colors.reset}`);
541
+ console.log(`${colors.green}║ @deinossrl/dgp-agent v1.2.6 ║${colors.reset}`);
487
542
  console.log(`${colors.green}╚═══════════════════════════════════════════════════════╝${colors.reset}`);
488
543
  console.log('');
489
544
 
@@ -599,7 +654,7 @@ async function showStatus() {
599
654
  function showHelp() {
600
655
  console.log(`
601
656
  ${colors.bold}${colors.cyan}DGP Agent - Despliegue-GPT Local Agent${colors.reset}
602
- ${colors.gray}@deinossrl/dgp-agent v1.1.0${colors.reset}
657
+ ${colors.gray}@deinossrl/dgp-agent v1.2.6${colors.reset}
603
658
 
604
659
  ${colors.bold}DESCRIPCIÓN${colors.reset}
605
660
  Agente local que reporta el estado de tu repositorio Git
@@ -646,6 +701,14 @@ ${colors.bold}REQUISITOS PARA DEPLOY${colors.reset}
646
701
  - rsync instalado (Linux/Mac) o equivalente (Windows)
647
702
  - Permisos sudo para reload nginx (vía sudoers sin password)
648
703
 
704
+ ${colors.bold}CHANGELOG${colors.reset}
705
+ ${colors.cyan}v1.2.6${colors.reset} - Comando git_commit_push desde la UI
706
+ ${colors.cyan}v1.2.5${colors.reset} - Sincronización de versiones y changelog
707
+ ${colors.cyan}v1.2.4${colors.reset} - Mejoras en ejecución async de comandos shell
708
+ ${colors.cyan}v1.2.0${colors.reset} - Modo deploy con polling de comandos remotos
709
+ ${colors.cyan}v1.1.0${colors.reset} - Soporte para deploy via rsync y reload nginx
710
+ ${colors.cyan}v1.0.0${colors.reset} - Versión inicial: reporte de estado git
711
+
649
712
  ${colors.bold}MÁS INFO${colors.reset}
650
713
  https://github.com/DEINOS-SRL/tenminuteia
651
714
  `);
@@ -674,7 +737,7 @@ switch (command) {
674
737
  case 'version':
675
738
  case '-v':
676
739
  case '--version':
677
- console.log('@deinossrl/dgp-agent v1.1.0');
740
+ console.log('@deinossrl/dgp-agent v1.2.6');
678
741
  break;
679
742
  default:
680
743
  runAgent(false); // Status-only mode
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deinossrl/dgp-agent",
3
- "version": "1.1.0",
3
+ "version": "1.2.6",
4
4
  "description": "Agente local para Despliegue-GPT - Reporta el estado del repositorio Git a la plataforma TenMinute IA",
5
5
  "main": "index.mjs",
6
6
  "bin": {