troxy-cli 1.7.0 → 1.7.1

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/bin/troxy.js +31 -10
  2. package/package.json +1 -1
package/bin/troxy.js CHANGED
@@ -365,21 +365,42 @@ switch (command) {
365
365
  // ── Restart MCP service ───────────────────────────────────────
366
366
  case 'restart': {
367
367
  const { execSync: _execSyncRestart } = await import('child_process');
368
- const os = (await import('os')).default;
369
- console.log('\n Restarting Troxy MCP service...');
368
+ const fsR = await import('fs');
369
+ const osR = (await import('os')).default;
370
+ console.log('\n Restarting Troxy service...');
370
371
  try {
371
- if (os.platform() === 'linux') {
372
+ if (osR.platform() === 'linux') {
373
+ // Migrate service file from old "troxy mcp" to "troxy daemon" if needed
374
+ const svcPath = '/etc/systemd/system/troxy-mcp.service';
375
+ if (fsR.existsSync(svcPath)) {
376
+ const svc = fsR.readFileSync(svcPath, 'utf8');
377
+ if (svc.includes('ExecStart=') && svc.includes(' mcp') && !svc.includes(' daemon')) {
378
+ const fixed = svc.replace(/(ExecStart=\S+) mcp/, '$1 daemon');
379
+ fsR.writeFileSync('/tmp/troxy-mcp.service', fixed);
380
+ _execSyncRestart('sudo mv /tmp/troxy-mcp.service /etc/systemd/system/troxy-mcp.service');
381
+ _execSyncRestart('sudo systemctl daemon-reload');
382
+ process.stdout.write(' Migrated service to daemon mode ✓\n');
383
+ }
384
+ }
372
385
  _execSyncRestart('sudo systemctl restart troxy-mcp', { stdio: 'inherit' });
373
- } else if (os.platform() === 'darwin') {
374
- const { homedir } = await import('os');
375
- _execSyncRestart(`launchctl unload ~/Library/LaunchAgents/io.troxy.mcp.plist 2>/dev/null; launchctl load ~/Library/LaunchAgents/io.troxy.mcp.plist`, { shell: true, stdio: 'inherit' });
386
+ } else if (osR.platform() === 'darwin') {
387
+ const plistPath = osR.homedir() + '/Library/LaunchAgents/ai.troxy.mcp.plist';
388
+ if (fsR.existsSync(plistPath)) {
389
+ const plist = fsR.readFileSync(plistPath, 'utf8');
390
+ if (plist.includes('<string>mcp</string>')) {
391
+ const fixed = plist.replace('<string>mcp</string>', '<string>daemon</string>');
392
+ fsR.writeFileSync(plistPath, fixed);
393
+ process.stdout.write(' Migrated service to daemon mode ✓\n');
394
+ }
395
+ }
396
+ _execSyncRestart(`launchctl unload ${plistPath} 2>/dev/null; launchctl load ${plistPath}`, { shell: true, stdio: 'inherit' });
376
397
  } else {
377
- console.error('\n Restart is only supported on Linux and macOS.\n On Windows, restart the Troxy MCP process manually.\n');
398
+ console.error('\n Restart is only supported on Linux and macOS.\n');
378
399
  process.exit(1);
379
400
  }
380
- console.log(' MCP service restarted ✓\n');
381
- } catch {
382
- console.error('\n Could not restart service. Try manually:\n Linux: sudo systemctl restart troxy-mcp\n macOS: launchctl unload/load ~/Library/LaunchAgents/io.troxy.mcp.plist\n');
401
+ console.log(' Service restarted ✓\n');
402
+ } catch (e) {
403
+ console.error('\n Could not restart service. Try manually:\n Linux: sudo systemctl restart troxy-mcp\n macOS: launchctl unload/load ~/Library/LaunchAgents/ai.troxy.mcp.plist\n');
383
404
  process.exit(1);
384
405
  }
385
406
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "troxy-cli",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "AI payment control — protect your agent's payments with policies",
5
5
  "type": "module",
6
6
  "bin": {