@deinossrl/dgp-agent 1.4.31 → 1.4.33

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 +17 -7
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -222,7 +222,15 @@ function saveSshKeyLocally(sshPrivateKey) {
222
222
 
223
223
  const keyPath = getDgpSshKeyPath();
224
224
  // Normalizar saltos de línea
225
- const normalizedKey = sshPrivateKey.replace(/\\n/g, '\n').replace(/\r\n/g, '\n');
225
+ let normalizedKey = sshPrivateKey.replace(/\\n/g, '\n').replace(/\r\n/g, '\n');
226
+
227
+ // Verificar si la key tiene los delimitadores BEGIN/END
228
+ if (!normalizedKey.includes('-----BEGIN')) {
229
+ console.log('[!] SSH Key sin delimitadores, agregándolos automáticamente...');
230
+ // Agregar header y footer OpenSSH
231
+ normalizedKey = `-----BEGIN OPENSSH PRIVATE KEY-----\n${normalizedKey}\n-----END OPENSSH PRIVATE KEY-----`;
232
+ }
233
+
226
234
  writeFileSync(keyPath, normalizedKey, { mode: 0o600 });
227
235
 
228
236
  return keyPath;
@@ -321,7 +329,7 @@ function getPlinkPath() {
321
329
  }
322
330
 
323
331
  // Versión del agente
324
- const AGENT_VERSION = '1.4.31';
332
+ const AGENT_VERSION = '1.4.33';
325
333
  let AGENT_MODE = 'smart'; // Siempre inteligente
326
334
 
327
335
  // Configuración (prioridad: env vars > archivo config > platform config > defaults)
@@ -1482,9 +1490,10 @@ async function executeTestConnection(command) {
1482
1490
  }
1483
1491
  }
1484
1492
  await addCommandLog('info', `Usando plink: ${plinkPath}`);
1485
- // Usar PowerShell para enviar "y" con Enter correctamente
1486
- const escapedPassword = sshPassword.replace(/"/g, '`"').replace(/\$/g, '`$');
1487
- sshCmd = `powershell -Command "Write-Output 'y' | & '${plinkPath}' -ssh -pw '${escapedPassword}' ${user}@${server_host} 'echo SSH_OK && hostname && whoami'"`;
1493
+ // Crear archivo temporal con respuesta "y" para auto-aceptar host key
1494
+ const tempFile = join(CONFIG_DIR, 'plink_input.txt');
1495
+ writeFileSync(tempFile, 'y\n');
1496
+ sshCmd = `cmd /c "type "${tempFile}" | "${plinkPath}" -ssh -pw "${sshPassword}" ${user}@${server_host} "echo SSH_OK && hostname && whoami""`;
1488
1497
  } else {
1489
1498
  // En Linux/Mac usar sshpass
1490
1499
  await addCommandLog('info', 'Usando sshpass (Linux/Mac)');
@@ -1512,8 +1521,9 @@ async function executeTestConnection(command) {
1512
1521
  throw new Error('No se pudo descargar plink. Instalá PuTTY manualmente o usá SSH Key.');
1513
1522
  }
1514
1523
  }
1515
- const escapedPassword2 = sshPassword.replace(/"/g, '`"').replace(/\$/g, '`$');
1516
- sshCmd = `powershell -Command "Write-Output 'y' | & '${plinkPath}' -ssh -pw '${escapedPassword2}' ${user}@${server_host} 'echo SSH_OK && hostname && whoami'"`;
1524
+ const tempFile = join(CONFIG_DIR, 'plink_input.txt');
1525
+ writeFileSync(tempFile, 'y\n');
1526
+ sshCmd = `cmd /c "type "${tempFile}" | "${plinkPath}" -ssh -pw "${sshPassword}" ${user}@${server_host} "echo SSH_OK && hostname && whoami""`;
1517
1527
  } else {
1518
1528
  sshCmd = `sshpass -p "${sshPassword}" ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 ${user}@${server_host} "echo 'SSH_OK' && hostname && whoami"`;
1519
1529
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deinossrl/dgp-agent",
3
- "version": "1.4.31",
3
+ "version": "1.4.33",
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": {