groove-dev 0.27.165 → 0.27.166

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@groove-dev/cli",
3
- "version": "0.27.165",
3
+ "version": "0.27.166",
4
4
  "description": "GROOVE CLI — manage AI coding agents from your terminal",
5
5
  "license": "FSL-1.1-Apache-2.0",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@groove-dev/daemon",
3
- "version": "0.27.165",
3
+ "version": "0.27.166",
4
4
  "description": "GROOVE daemon — agent orchestration engine",
5
5
  "license": "FSL-1.1-Apache-2.0",
6
6
  "type": "module",
@@ -479,6 +479,10 @@ export class TunnelManager {
479
479
  // Remote is behind npm — upgrade
480
480
  this.daemon.broadcast({ type: 'tunnel.status', data: { id, step: 'upgrading', from: remoteVer, to: npmVer } });
481
481
 
482
+ const target = `${config.user}@${config.host}`;
483
+ const keyArgs = config.sshKeyPath ? ['-i', config.sshKeyPath] : [];
484
+ const sshBase = [...keyArgs, '-p', String(config.port || 22), '-o', 'ConnectTimeout=10', '-o', 'BatchMode=yes', target];
485
+
482
486
  const installCmd = npmGlobalInstall(`groove-dev@${npmVer}`, config.user);
483
487
  const cleanupCmd = 'rm -rf $(npm root -g)/.groove-dev-* $(npm root -g)/groove-dev 2>/dev/null || true';
484
488
 
@@ -496,40 +500,43 @@ export class TunnelManager {
496
500
  }
497
501
  }
498
502
 
499
- // Restart remote daemon
503
+ // Restart remote daemon — fire and forget the SSH, verify through the tunnel
500
504
  const cdPrefix = config.projectDir ? `cd "${config.projectDir}" && ` : '';
501
- const setProjectDir = config.projectDir
502
- ? `curl -sf -X POST -H 'Content-Type: application/json' --data '{"path":"${config.projectDir}"}' http://localhost:${REMOTE_PORT}/api/project-dir > /dev/null 2>&1 || true; `
503
- : '';
504
- const restartCmd = `kill $(lsof -t -i:${REMOTE_PORT}) 2>/dev/null || true; sleep 2; ${cdPrefix}GROOVE_BIN=$(which groove) && nohup "$GROOVE_BIN" start > /tmp/groove-daemon.log 2>&1 < /dev/null & disown; sleep 4; curl -sf http://localhost:${REMOTE_PORT}/api/status && (${setProjectDir}true) || true`;
505
- execFileSync('ssh', [...sshBase, sshCmd(restartCmd)], {
506
- encoding: 'utf8', timeout: 60000, stdio: ['pipe', 'pipe', 'pipe'],
507
- });
505
+ try {
506
+ execFileSync('ssh', [...sshBase, sshCmd(`kill $(lsof -t -i:${REMOTE_PORT}) 2>/dev/null || true; sleep 1; ${cdPrefix}GROOVE_BIN=$(which groove) && nohup "$GROOVE_BIN" start > /tmp/groove-daemon.log 2>&1 < /dev/null & disown`)], {
507
+ encoding: 'utf8', timeout: 15000, stdio: ['pipe', 'pipe', 'pipe'],
508
+ });
509
+ } catch { /* SSH may close before nohup finishes — that's fine */ }
508
510
 
509
- // Verify through tunnel
511
+ // Wait for daemon to come back up through the existing tunnel
512
+ this.daemon.broadcast({ type: 'tunnel.status', data: { id, step: 'starting' } });
510
513
  let daemonVer = null;
511
- for (let i = 0; i < 3; i++) {
514
+ for (let i = 0; i < 8; i++) {
515
+ await new Promise(r => setTimeout(r, 2000));
512
516
  try {
513
- const check = await fetch(`http://localhost:${localPort}/api/status`, {
514
- signal: AbortSignal.timeout(3000),
515
- });
517
+ const check = await fetch(`http://localhost:${localPort}/api/status`, { signal: AbortSignal.timeout(3000) });
516
518
  if (check.ok) {
517
519
  daemonVer = (await check.json()).version || null;
518
520
  break;
519
521
  }
520
- } catch { /* retry */ }
521
- await new Promise(r => setTimeout(r, 2000));
522
+ } catch { /* not up yet */ }
522
523
  }
523
524
 
524
- const localVer = getLocalVersion();
525
- if (daemonVer) {
526
- this.daemon.broadcast({ type: 'tunnel.version-info', data: { id, localVersion: localVer, remoteVersion: daemonVer, match: daemonVer === localVer } });
527
- } else {
528
- this.daemon.broadcast({ type: 'tunnel.upgrade-failed', data: { id, error: 'Daemon did not respond after restart', from: remoteVer, attempted: npmVer } });
525
+ if (config.projectDir && daemonVer) {
526
+ try {
527
+ await fetch(`http://localhost:${localPort}/api/project-dir`, {
528
+ method: 'POST', headers: { 'Content-Type': 'application/json' },
529
+ body: JSON.stringify({ path: config.projectDir }),
530
+ signal: AbortSignal.timeout(3000),
531
+ });
532
+ } catch { /* best effort */ }
529
533
  }
530
534
 
535
+ const localVer = getLocalVersion();
536
+ this.daemon.broadcast({ type: 'tunnel.version-info', data: { id, localVersion: localVer, remoteVersion: daemonVer || npmVer, match: (daemonVer || npmVer) === localVer } });
531
537
  this.daemon.audit.log('tunnel.upgrade', { id, from: remoteVer, to: daemonVer || npmVer });
532
538
  } catch (err) {
539
+ // Upgrade failed but tunnel may still work — check before reporting failure
533
540
  try {
534
541
  const verify = await fetch(`http://localhost:${localPort}/api/status`, { signal: AbortSignal.timeout(5000) });
535
542
  if (verify.ok) {
@@ -537,7 +544,7 @@ export class TunnelManager {
537
544
  this.daemon.broadcast({ type: 'tunnel.version-info', data: { id, localVersion: getLocalVersion(), remoteVersion: verifyData.version, match: false } });
538
545
  return;
539
546
  }
540
- } catch { /* tunnel verification failed */ }
547
+ } catch { /* tunnel down */ }
541
548
  this.daemon.broadcast({ type: 'tunnel.upgrade-failed', data: { id, error: err.message } });
542
549
  }
543
550
  }