tuna-agent 0.1.166 → 0.1.167

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.
@@ -224,6 +224,18 @@ export class AgentWebSocketClient {
224
224
  return this.ws !== null && this.ws.readyState === WebSocket.OPEN;
225
225
  }
226
226
  _connect() {
227
+ // Tear down any previous socket first. Without this, a reconnect could leak the
228
+ // old connection: it stays half-open on the server (readyState OPEN) and becomes
229
+ // a zombie the API keeps sending to, while this daemon listens on the new one.
230
+ if (this.ws) {
231
+ try {
232
+ this.ws.removeAllListeners();
233
+ this.ws.terminate();
234
+ }
235
+ catch { /* ignore */ }
236
+ this.ws = null;
237
+ }
238
+ this._stopHeartbeat();
227
239
  try {
228
240
  this.ws = new WebSocket(this.config.wsUrl, {
229
241
  headers: { 'Authorization': `Bearer ${this.config.agentToken}` },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tuna-agent",
3
- "version": "0.1.166",
3
+ "version": "0.1.167",
4
4
  "description": "Tuna Agent - Run AI coding tasks on your machine",
5
5
  "bin": {
6
6
  "tuna-agent": "dist/cli/index.js"