@dmsdc-ai/aigentry-telepty 0.1.87 → 0.1.88
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/cli.js +28 -6
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -334,8 +334,22 @@ function printSessionInfo(session, options = {}) {
|
|
|
334
334
|
console.log('');
|
|
335
335
|
}
|
|
336
336
|
|
|
337
|
+
function resolveTeleptyEntryPoint() {
|
|
338
|
+
// After npm upgrade, process.argv[1] still points to the OLD version's cli.js.
|
|
339
|
+
// Resolve the current telepty binary from PATH, which npm updates on install.
|
|
340
|
+
try {
|
|
341
|
+
const cmd = process.platform === 'win32' ? 'where telepty' : 'which telepty';
|
|
342
|
+
const binPath = execSync(cmd, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim().split('\n')[0];
|
|
343
|
+
if (binPath && fs.existsSync(binPath)) {
|
|
344
|
+
return fs.realpathSync(binPath);
|
|
345
|
+
}
|
|
346
|
+
} catch {}
|
|
347
|
+
return process.argv[1];
|
|
348
|
+
}
|
|
349
|
+
|
|
337
350
|
function startDetachedDaemon() {
|
|
338
|
-
const
|
|
351
|
+
const entryPoint = resolveTeleptyEntryPoint();
|
|
352
|
+
const cp = spawn(process.argv[0], [entryPoint, 'daemon'], {
|
|
339
353
|
detached: true,
|
|
340
354
|
stdio: 'ignore'
|
|
341
355
|
});
|
|
@@ -391,7 +405,11 @@ async function repairLocalDaemon(options = {}) {
|
|
|
391
405
|
startDetachedDaemon();
|
|
392
406
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
393
407
|
const meta = await getDaemonMeta('127.0.0.1');
|
|
394
|
-
|
|
408
|
+
const versionMatch = meta && meta.version === pkg.version;
|
|
409
|
+
if (meta && !versionMatch) {
|
|
410
|
+
process.stdout.write(`\x1b[33m⚠️ Daemon restarted but version mismatch (running v${meta.version}, expected v${pkg.version})\x1b[0m\n`);
|
|
411
|
+
}
|
|
412
|
+
return { stopped: results.stopped.length, failed: results.failed.length, meta, versionMatch };
|
|
395
413
|
}
|
|
396
414
|
|
|
397
415
|
function getDiscoveryHosts() {
|
|
@@ -455,10 +473,14 @@ async function ensureDaemonRunning(options = {}) {
|
|
|
455
473
|
});
|
|
456
474
|
|
|
457
475
|
if (sessionsRes.ok && hasCapabilities) {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
476
|
+
// Version mismatch: running daemon is older than installed CLI
|
|
477
|
+
if (meta && meta.version !== pkg.version) {
|
|
478
|
+
process.stdout.write(`\x1b[33m⚙️ Daemon version mismatch (running v${meta.version}, installed v${pkg.version}). Restarting...\x1b[0m\n`);
|
|
479
|
+
cleanupDaemonProcesses();
|
|
480
|
+
} else {
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
} else if (sessionsRes.ok && !meta) {
|
|
462
484
|
process.stdout.write('\x1b[33m⚙️ Found an older local telepty daemon. Restarting it...\x1b[0m\n');
|
|
463
485
|
cleanupDaemonProcesses();
|
|
464
486
|
} else if (sessionsRes.ok && meta) {
|