@exotel-npm-dev/exotel-ai-assist 1.2.0 → 1.2.2

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
  }
@@ -1809,9 +1809,11 @@ class ExotelAIAssistController extends EventEmitter {
1809
1809
  _handleStreamStatus(state) {
1810
1810
  this._streamState = state;
1811
1811
  this.emit("streamState", state);
1812
- // We are firing ready because we need to show the UI immediately when the stream is connected or throttled.
1813
1812
  if (state === "connected" || state === "throttled") {
1814
1813
  this._fireReady();
1814
+ } else if (state === "disconnected" && this.readyFired) {
1815
+ this.readyFired = false;
1816
+ this.emit("onReady", false);
1815
1817
  }
1816
1818
  }
1817
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
  }
@@ -21227,9 +21227,11 @@ class ExotelAIAssistController extends EventEmitter {
21227
21227
  _handleStreamStatus(state) {
21228
21228
  this._streamState = state;
21229
21229
  this.emit("streamState", state);
21230
- // We are firing ready because we need to show the UI immediately when the stream is connected or throttled.
21231
21230
  if (state === "connected" || state === "throttled") {
21232
21231
  this._fireReady();
21232
+ } else if (state === "disconnected" && this.readyFired) {
21233
+ this.readyFired = false;
21234
+ this.emit("onReady", false);
21233
21235
  }
21234
21236
  }
21235
21237
  _setStatus(status) {
@@ -21888,6 +21890,23 @@ function ExotelAIAssist(_a) {
21888
21890
  (_a = onReadyRef.current) === null || _a === void 0 ? void 0 : _a.call(onReadyRef, isReady);
21889
21891
  }, [isReady]);
21890
21892
  const connected = streamState === "connected";
21893
+ function renderProperEmptyContent() {
21894
+ if (streamState === "throttled") {
21895
+ return jsxRuntimeExports.jsx(EmptyState, {
21896
+ title: "AI Assist Unavailable",
21897
+ subtitle: "Available again on your next call",
21898
+ showWarningBanner: true,
21899
+ warningBannerMessage: "AI Assist couldn't join this call \u2014 capacity is full. It should be ready for your next call."
21900
+ });
21901
+ }
21902
+ if (streamState === "disconnected") {
21903
+ return jsxRuntimeExports.jsx(EmptyState, {
21904
+ title: "AI Assist is currently inactive",
21905
+ subtitle: "we were unable to establish a connection."
21906
+ });
21907
+ }
21908
+ return null;
21909
+ }
21891
21910
  return jsxRuntimeExports.jsx(Provider, {
21892
21911
  children: jsxRuntimeExports.jsx("div", {
21893
21912
  className: "oa-theme-root",
@@ -21954,12 +21973,7 @@ function ExotelAIAssist(_a) {
21954
21973
  botConfig: botConfig
21955
21974
  })
21956
21975
  })]
21957
- }) : jsxRuntimeExports.jsx(EmptyState, {
21958
- title: "AI Assist Unavailable",
21959
- subtitle: "Available again on your next call",
21960
- showWarningBanner: true,
21961
- warningBannerMessage: "AI Assist couldn't join this call \u2014 capacity is full. It should be ready for your next call."
21962
- })]
21976
+ }) : renderProperEmptyContent()]
21963
21977
  })
21964
21978
  })
21965
21979
  })
@@ -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
  }
@@ -6513,9 +6513,11 @@ class ExotelAIAssistController extends EventEmitter {
6513
6513
  _handleStreamStatus(state) {
6514
6514
  this._streamState = state;
6515
6515
  this.emit("streamState", state);
6516
- // We are firing ready because we need to show the UI immediately when the stream is connected or throttled.
6517
6516
  if (state === "connected" || state === "throttled") {
6518
6517
  this._fireReady();
6518
+ } else if (state === "disconnected" && this.readyFired) {
6519
+ this.readyFired = false;
6520
+ this.emit("onReady", false);
6519
6521
  }
6520
6522
  }
6521
6523
  _setStatus(status) {
@@ -7174,6 +7176,23 @@ function ExotelAIAssist(_a) {
7174
7176
  (_a = onReadyRef.current) === null || _a === void 0 ? void 0 : _a.call(onReadyRef, isReady);
7175
7177
  }, [isReady]);
7176
7178
  const connected = streamState === "connected";
7179
+ function renderProperEmptyContent() {
7180
+ if (streamState === "throttled") {
7181
+ return jsxRuntime.jsx(EmptyState, {
7182
+ title: "AI Assist Unavailable",
7183
+ subtitle: "Available again on your next call",
7184
+ showWarningBanner: true,
7185
+ warningBannerMessage: "AI Assist couldn't join this call \u2014 capacity is full. It should be ready for your next call."
7186
+ });
7187
+ }
7188
+ if (streamState === "disconnected") {
7189
+ return jsxRuntime.jsx(EmptyState, {
7190
+ title: "AI Assist is currently inactive",
7191
+ subtitle: "we were unable to establish a connection."
7192
+ });
7193
+ }
7194
+ return null;
7195
+ }
7177
7196
  return jsxRuntime.jsx(Provider, {
7178
7197
  children: jsxRuntime.jsx("div", {
7179
7198
  className: "oa-theme-root",
@@ -7240,12 +7259,7 @@ function ExotelAIAssist(_a) {
7240
7259
  botConfig: botConfig
7241
7260
  })
7242
7261
  })]
7243
- }) : jsxRuntime.jsx(EmptyState, {
7244
- title: "AI Assist Unavailable",
7245
- subtitle: "Available again on your next call",
7246
- showWarningBanner: true,
7247
- warningBannerMessage: "AI Assist couldn't join this call \u2014 capacity is full. It should be ready for your next call."
7248
- })]
7262
+ }) : renderProperEmptyContent()]
7249
7263
  })
7250
7264
  })
7251
7265
  })
@@ -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.2.0",
3
+ "version": "1.2.2",
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",
@@ -30,6 +30,23 @@ export function ExotelAIAssist({ className, onReady, ...params }: ExotelAIAssist
30
30
 
31
31
  const connected = streamState === "connected";
32
32
 
33
+ function renderProperEmptyContent(): JSX.Element | null {
34
+ if (streamState === "throttled") {
35
+ return (
36
+ <EmptyState
37
+ title="AI Assist Unavailable"
38
+ subtitle="Available again on your next call"
39
+ showWarningBanner={true}
40
+ warningBannerMessage="AI Assist couldn't join this call — capacity is full. It should be ready for your next call."
41
+ />
42
+ );
43
+ }
44
+ if (streamState === "disconnected") {
45
+ return <EmptyState title="AI Assist is currently inactive" subtitle="we were unable to establish a connection." />;
46
+ }
47
+ return null;
48
+ }
49
+
33
50
  return (
34
51
  <Tooltip.Provider>
35
52
  <div className="oa-theme-root">
@@ -60,12 +77,7 @@ export function ExotelAIAssist({ className, onReady, ...params }: ExotelAIAssist
60
77
  </Tabs.Content>
61
78
  </Tabs.Root>
62
79
  ) : (
63
- <EmptyState
64
- title="AI Assist Unavailable"
65
- subtitle="Available again on your next call"
66
- showWarningBanner={true}
67
- warningBannerMessage="AI Assist couldn't join this call — capacity is full. It should be ready for your next call."
68
- />
80
+ renderProperEmptyContent()
69
81
  )}
70
82
  </div>
71
83
  </div>
@@ -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
  }
@@ -262,9 +262,11 @@ export class ExotelAIAssistController extends EventEmitter<ControllerEvents> {
262
262
  private _handleStreamStatus(state: StreamState): void {
263
263
  this._streamState = state;
264
264
  this.emit("streamState", state);
265
- // We are firing ready because we need to show the UI immediately when the stream is connected or throttled.
266
265
  if (state === "connected" || state === "throttled") {
267
266
  this._fireReady();
267
+ } else if (state === "disconnected" && this.readyFired) {
268
+ this.readyFired = false;
269
+ this.emit("onReady", false);
268
270
  }
269
271
  }
270
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