@applica-software-guru/persona-sdk 0.1.64 → 0.1.66

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.
@@ -59,18 +59,26 @@ class PersonaWebSocketProtocol extends PersonaProtocolBase {
59
59
  const data = JSON.parse(event.data) as PersonaPacket;
60
60
  this.notifyPacket(data);
61
61
  });
62
- this.webSocket.addEventListener('close', () => {
62
+ this.webSocket.addEventListener('close', (event: CloseEvent) => {
63
63
  this.setStatus('disconnected');
64
64
  this.webSocket = null;
65
- this.config.logger?.warn('WebSocket connection closed');
65
+ if (event.code !== 1000) {
66
+ this.notifyPacket({
67
+ type: 'message',
68
+ payload: {
69
+ role: 'assistant',
70
+ type: 'text',
71
+ text: 'Oops! The connection to the server was lost. Please try again later.',
72
+ },
73
+ });
74
+ this.config.logger?.warn('WebSocket connection closed');
75
+ }
66
76
  });
67
77
 
68
- this.webSocket.addEventListener('error', (error) => {
78
+ this.webSocket.addEventListener('error', () => {
69
79
  this.setStatus('disconnected');
70
80
  this.webSocket = null;
71
- this.config.logger?.error('WebSocket error', error);
72
-
73
- // TODO: Implement reconnection logic
81
+ this.config.logger?.error('WebSocket connection error');
74
82
  });
75
83
 
76
84
  return Promise.resolve(sid);