remote-cli-agent 0.3.2 → 0.4.0

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.
@@ -48,8 +48,8 @@ function doConnect() {
48
48
  const reasonStr = reason.toString() || 'unknown';
49
49
  console.log(`Disconnected from server (code: ${code}, reason: ${reasonStr})`);
50
50
  isConnected = false;
51
- // Don't reconnect if we were replaced - another instance is already connected
52
- if (reasonStr === 'Replaced by new connection') {
51
+ // Don't reconnect if we were replaced (code 4000 or legacy 1000 with reason)
52
+ if (code === 4000 || reasonStr === 'Replaced by new connection' || reasonStr === 'Replaced') {
53
53
  console.log('Another agent instance took over. Exiting.');
54
54
  process.exit(0);
55
55
  }
@@ -85,6 +85,11 @@ function handleMessage(msg) {
85
85
  sendMessage({ type: 'sessions_update', sessions: getSessionList() });
86
86
  break;
87
87
  }
88
+ case 'terminated': {
89
+ console.log('Server terminated this connection. Another agent took over. Exiting.');
90
+ process.exit(0);
91
+ break;
92
+ }
88
93
  default:
89
94
  console.warn('Unknown message type from server:', msg.type);
90
95
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remote-cli-agent",
3
- "version": "0.3.2",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "remote-cli": "./dist/index.js"