@exotel-npm-dev/exotel-ai-assist 1.1.9 → 1.2.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.
@@ -1623,7 +1623,7 @@ class ExotelAIAssistController extends EventEmitter {
1623
1623
  var _a;
1624
1624
  this._clearReconnectTimer();
1625
1625
  (_a = this.transport) === null || _a === void 0 ? void 0 : _a.disconnect();
1626
- if (this.readyFired) {
1626
+ if (this.readyFired && this._streamState !== "throttled") {
1627
1627
  this.readyFired = false;
1628
1628
  this.emit("onReady", false);
1629
1629
  }
@@ -1685,7 +1685,8 @@ class ExotelAIAssistController extends EventEmitter {
1685
1685
  break;
1686
1686
  case "DISCONNECTED":
1687
1687
  if (this.connectionEstablished) {
1688
- if (this.readyFired) {
1688
+ const wasThrottled = this._streamState === "throttled";
1689
+ if (this.readyFired && !wasThrottled) {
1689
1690
  this.readyFired = false;
1690
1691
  this.emit("onReady", false);
1691
1692
  }
@@ -1808,9 +1809,11 @@ class ExotelAIAssistController extends EventEmitter {
1808
1809
  _handleStreamStatus(state) {
1809
1810
  this._streamState = state;
1810
1811
  this.emit("streamState", state);
1811
- // We are firing ready because we need to show the UI immediately when the stream is connected or throttled.
1812
1812
  if (state === "connected" || state === "throttled") {
1813
1813
  this._fireReady();
1814
+ } else if (state === "disconnected" && this.readyFired) {
1815
+ this.readyFired = false;
1816
+ this.emit("onReady", false);
1814
1817
  }
1815
1818
  }
1816
1819
  _setStatus(status) {
package/dist/index.js CHANGED
@@ -21041,7 +21041,7 @@ class ExotelAIAssistController extends EventEmitter {
21041
21041
  var _a;
21042
21042
  this._clearReconnectTimer();
21043
21043
  (_a = this.transport) === null || _a === void 0 ? void 0 : _a.disconnect();
21044
- if (this.readyFired) {
21044
+ if (this.readyFired && this._streamState !== "throttled") {
21045
21045
  this.readyFired = false;
21046
21046
  this.emit("onReady", false);
21047
21047
  }
@@ -21103,7 +21103,8 @@ class ExotelAIAssistController extends EventEmitter {
21103
21103
  break;
21104
21104
  case "DISCONNECTED":
21105
21105
  if (this.connectionEstablished) {
21106
- if (this.readyFired) {
21106
+ const wasThrottled = this._streamState === "throttled";
21107
+ if (this.readyFired && !wasThrottled) {
21107
21108
  this.readyFired = false;
21108
21109
  this.emit("onReady", false);
21109
21110
  }
@@ -21226,9 +21227,11 @@ class ExotelAIAssistController extends EventEmitter {
21226
21227
  _handleStreamStatus(state) {
21227
21228
  this._streamState = state;
21228
21229
  this.emit("streamState", state);
21229
- // We are firing ready because we need to show the UI immediately when the stream is connected or throttled.
21230
21230
  if (state === "connected" || state === "throttled") {
21231
21231
  this._fireReady();
21232
+ } else if (state === "disconnected" && this.readyFired) {
21233
+ this.readyFired = false;
21234
+ this.emit("onReady", false);
21232
21235
  }
21233
21236
  }
21234
21237
  _setStatus(status) {
@@ -6327,7 +6327,7 @@ class ExotelAIAssistController extends EventEmitter {
6327
6327
  var _a;
6328
6328
  this._clearReconnectTimer();
6329
6329
  (_a = this.transport) === null || _a === void 0 ? void 0 : _a.disconnect();
6330
- if (this.readyFired) {
6330
+ if (this.readyFired && this._streamState !== "throttled") {
6331
6331
  this.readyFired = false;
6332
6332
  this.emit("onReady", false);
6333
6333
  }
@@ -6389,7 +6389,8 @@ class ExotelAIAssistController extends EventEmitter {
6389
6389
  break;
6390
6390
  case "DISCONNECTED":
6391
6391
  if (this.connectionEstablished) {
6392
- if (this.readyFired) {
6392
+ const wasThrottled = this._streamState === "throttled";
6393
+ if (this.readyFired && !wasThrottled) {
6393
6394
  this.readyFired = false;
6394
6395
  this.emit("onReady", false);
6395
6396
  }
@@ -6512,9 +6513,11 @@ class ExotelAIAssistController extends EventEmitter {
6512
6513
  _handleStreamStatus(state) {
6513
6514
  this._streamState = state;
6514
6515
  this.emit("streamState", state);
6515
- // We are firing ready because we need to show the UI immediately when the stream is connected or throttled.
6516
6516
  if (state === "connected" || state === "throttled") {
6517
6517
  this._fireReady();
6518
+ } else if (state === "disconnected" && this.readyFired) {
6519
+ this.readyFired = false;
6520
+ this.emit("onReady", false);
6518
6521
  }
6519
6522
  }
6520
6523
  _setStatus(status) {
@@ -38,7 +38,7 @@ export type ConnectionStatus = "idle" | "connecting" | "connected" | "disconnect
38
38
  * - `throttled` – capacity full; the bot cannot join this call
39
39
  * - `pending` – stream is pending
40
40
  */
41
- export type StreamState = "connected" | "throttled" | "pending";
41
+ export type StreamState = "connected" | "throttled" | "pending" | "disconnected";
42
42
  /** Feature-flag config received from the AI Assist backend. */
43
43
  export interface BotConfig {
44
44
  sentiment: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exotel-npm-dev/exotel-ai-assist",
3
- "version": "1.1.9",
3
+ "version": "1.2.1",
4
4
  "description": "AI-powered real-time suggestions, transcript, and sentiment for agent calls",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",
@@ -55,7 +55,7 @@ export class ExotelAIAssistController extends EventEmitter<ControllerEvents> {
55
55
  disconnect(): void {
56
56
  this._clearReconnectTimer();
57
57
  this.transport?.disconnect();
58
- if (this.readyFired) {
58
+ if (this.readyFired && this._streamState !== "throttled") {
59
59
  this.readyFired = false;
60
60
  this.emit("onReady", false);
61
61
  }
@@ -120,7 +120,8 @@ export class ExotelAIAssistController extends EventEmitter<ControllerEvents> {
120
120
 
121
121
  case "DISCONNECTED":
122
122
  if (this.connectionEstablished) {
123
- if (this.readyFired) {
123
+ const wasThrottled = this._streamState === "throttled";
124
+ if (this.readyFired && !wasThrottled) {
124
125
  this.readyFired = false;
125
126
  this.emit("onReady", false);
126
127
  }
@@ -261,9 +262,11 @@ export class ExotelAIAssistController extends EventEmitter<ControllerEvents> {
261
262
  private _handleStreamStatus(state: StreamState): void {
262
263
  this._streamState = state;
263
264
  this.emit("streamState", state);
264
- // We are firing ready because we need to show the UI immediately when the stream is connected or throttled.
265
265
  if (state === "connected" || state === "throttled") {
266
266
  this._fireReady();
267
+ } else if (state === "disconnected" && this.readyFired) {
268
+ this.readyFired = false;
269
+ this.emit("onReady", false);
267
270
  }
268
271
  }
269
272
 
@@ -43,7 +43,7 @@ export type ConnectionStatus = "idle" | "connecting" | "connected" | "disconnect
43
43
  * - `throttled` – capacity full; the bot cannot join this call
44
44
  * - `pending` – stream is pending
45
45
  */
46
- export type StreamState = "connected" | "throttled" | "pending";
46
+ export type StreamState = "connected" | "throttled" | "pending" | "disconnected";
47
47
 
48
48
  // ---------------------------------------------------------------------------
49
49
  // Internal-only backend response types