@deinossrl/dgp-agent 1.4.36 → 1.4.37

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 +33 -5
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -221,8 +221,14 @@ function saveSshKeyLocally(sshPrivateKey) {
221
221
  }
222
222
 
223
223
  const keyPath = getDgpSshKeyPath();
224
- // Normalizar saltos de línea
225
- let normalizedKey = sshPrivateKey.replace(/\\n/g, '\n').replace(/\r\n/g, '\n');
224
+
225
+ // Normalizar la key: los saltos de línea pueden venir ya interpretados o como \n literal
226
+ let normalizedKey = sshPrivateKey;
227
+
228
+ // Si no tiene saltos de línea reales pero tiene \n literal, convertirlos
229
+ if (!normalizedKey.includes('\n') && normalizedKey.includes('\\n')) {
230
+ normalizedKey = normalizedKey.replace(/\\n/g, '\n');
231
+ }
226
232
 
227
233
  // Verificar si la key tiene los delimitadores BEGIN/END
228
234
  if (!normalizedKey.includes('-----BEGIN')) {
@@ -346,7 +352,7 @@ function getPlinkPath() {
346
352
  }
347
353
 
348
354
  // Versión del agente
349
- const AGENT_VERSION = '1.4.36';
355
+ const AGENT_VERSION = '1.4.37';
350
356
  let AGENT_MODE = 'smart'; // Siempre inteligente
351
357
 
352
358
  // Configuración (prioridad: env vars > archivo config > platform config > defaults)
@@ -1179,9 +1185,31 @@ async function executeDeploy(command) {
1179
1185
  const fs = await import('fs');
1180
1186
  const path = await import('path');
1181
1187
  sshKeyPath = path.join(os.tmpdir(), `dgp_deploy_key_${Date.now()}`);
1182
- // Normalizar saltos de línea (pueden venir como \n literal del JSON)
1183
- const normalizedKey = sshPrivateKey.replace(/\\n/g, '\n').replace(/\r\n/g, '\n');
1188
+
1189
+ // Normalizar la key: los saltos de línea pueden venir ya interpretados o como \n literal
1190
+ let normalizedKey = sshPrivateKey;
1191
+
1192
+ // Si no tiene saltos de línea reales pero tiene \n literal, convertirlos
1193
+ if (!normalizedKey.includes('\n') && normalizedKey.includes('\\n')) {
1194
+ normalizedKey = normalizedKey.replace(/\\n/g, '\n');
1195
+ }
1196
+
1197
+ // Asegurar que termina con salto de línea
1198
+ if (!normalizedKey.endsWith('\n')) {
1199
+ normalizedKey += '\n';
1200
+ }
1201
+
1184
1202
  fs.writeFileSync(sshKeyPath, normalizedKey, { mode: 0o600 });
1203
+
1204
+ // En Windows, ajustar permisos con icacls
1205
+ if (process.platform === 'win32') {
1206
+ try {
1207
+ shellSync(`icacls "${sshKeyPath}" /inheritance:r /grant:r "%USERNAME%:(R,W)"`);
1208
+ } catch (e) {
1209
+ // Ignorar si falla
1210
+ }
1211
+ }
1212
+
1185
1213
  sshOptions = `-e "ssh -i ${sshKeyPath} -o StrictHostKeyChecking=no"`;
1186
1214
  }
1187
1215
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deinossrl/dgp-agent",
3
- "version": "1.4.36",
3
+ "version": "1.4.37",
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": {