@exotel-npm-dev/exotel-ai-assist 1.0.9 → 1.1.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.
|
@@ -6,7 +6,6 @@ export declare class ExotelAIAssistController extends EventEmitter<ControllerEve
|
|
|
6
6
|
private status;
|
|
7
7
|
private destroyed;
|
|
8
8
|
private connectionEstablished;
|
|
9
|
-
private _acknowledged;
|
|
10
9
|
private reconnectAttempt;
|
|
11
10
|
private reconnectTimer;
|
|
12
11
|
private static readonly MAX_RECONNECT_ATTEMPTS;
|
package/dist/controller/index.js
CHANGED
|
@@ -1595,7 +1595,6 @@ class ExotelAIAssistController extends EventEmitter {
|
|
|
1595
1595
|
// connectionEstablished === false → connection never opened → retry
|
|
1596
1596
|
// connectionEstablished === true → server ended a live connection → destroy
|
|
1597
1597
|
this.connectionEstablished = false;
|
|
1598
|
-
this._acknowledged = false;
|
|
1599
1598
|
this.reconnectAttempt = 0;
|
|
1600
1599
|
this.reconnectTimer = null;
|
|
1601
1600
|
this.params = Object.assign({}, params);
|
|
@@ -1604,7 +1603,6 @@ class ExotelAIAssistController extends EventEmitter {
|
|
|
1604
1603
|
if (this.destroyed) return;
|
|
1605
1604
|
this._clearReconnectTimer();
|
|
1606
1605
|
this.connectionEstablished = false;
|
|
1607
|
-
this._acknowledged = false;
|
|
1608
1606
|
this.reconnectAttempt = 0;
|
|
1609
1607
|
this._setStatus("connecting");
|
|
1610
1608
|
this._ensureTransport();
|
|
@@ -1624,7 +1622,6 @@ class ExotelAIAssistController extends EventEmitter {
|
|
|
1624
1622
|
if (hashChanged) {
|
|
1625
1623
|
this._clearReconnectTimer();
|
|
1626
1624
|
this.connectionEstablished = false;
|
|
1627
|
-
this._acknowledged = false;
|
|
1628
1625
|
this.reconnectAttempt = 0;
|
|
1629
1626
|
// Tear down the current transport and start fresh with the new params.
|
|
1630
1627
|
(_a = this.transport) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
@@ -1705,7 +1702,6 @@ class ExotelAIAssistController extends EventEmitter {
|
|
|
1705
1702
|
var _a;
|
|
1706
1703
|
if (this.destroyed) return;
|
|
1707
1704
|
this.connectionEstablished = false;
|
|
1708
|
-
this._acknowledged = false;
|
|
1709
1705
|
(_a = this.transport) === null || _a === void 0 ? void 0 : _a.connect(Utils.buildWsUrl(this.params), this.params.authToken);
|
|
1710
1706
|
}, delay);
|
|
1711
1707
|
}
|
|
@@ -1736,10 +1732,6 @@ class ExotelAIAssistController extends EventEmitter {
|
|
|
1736
1732
|
this.emit("error", err);
|
|
1737
1733
|
return;
|
|
1738
1734
|
}
|
|
1739
|
-
if (!this._acknowledged && msgType === "ack") {
|
|
1740
|
-
this._acknowledged = true;
|
|
1741
|
-
this.emit("acknowledged");
|
|
1742
|
-
}
|
|
1743
1735
|
if (parsed.config) {
|
|
1744
1736
|
this.emit("botConfig", parsed.config);
|
|
1745
1737
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { ExotelAIAssistParams, Suggestion, TranscriptLine, Sentiment, BotConfig, ConnectionStatus } from "../types";
|
|
2
2
|
export interface UseExotelAIAssistReturn {
|
|
3
3
|
status: ConnectionStatus;
|
|
4
|
-
/** True once the server has acknowledged the connection (first valid payload after auth). */
|
|
5
|
-
isAcknowledged: boolean;
|
|
6
4
|
/** AI suggestions, oldest first, capped at 50. */
|
|
7
5
|
suggestions: Suggestion[];
|
|
8
6
|
/** Live transcript lines, ordered by start time. */
|
package/dist/index.js
CHANGED
|
@@ -21013,7 +21013,6 @@ class ExotelAIAssistController extends EventEmitter {
|
|
|
21013
21013
|
// connectionEstablished === false → connection never opened → retry
|
|
21014
21014
|
// connectionEstablished === true → server ended a live connection → destroy
|
|
21015
21015
|
this.connectionEstablished = false;
|
|
21016
|
-
this._acknowledged = false;
|
|
21017
21016
|
this.reconnectAttempt = 0;
|
|
21018
21017
|
this.reconnectTimer = null;
|
|
21019
21018
|
this.params = Object.assign({}, params);
|
|
@@ -21022,7 +21021,6 @@ class ExotelAIAssistController extends EventEmitter {
|
|
|
21022
21021
|
if (this.destroyed) return;
|
|
21023
21022
|
this._clearReconnectTimer();
|
|
21024
21023
|
this.connectionEstablished = false;
|
|
21025
|
-
this._acknowledged = false;
|
|
21026
21024
|
this.reconnectAttempt = 0;
|
|
21027
21025
|
this._setStatus("connecting");
|
|
21028
21026
|
this._ensureTransport();
|
|
@@ -21042,7 +21040,6 @@ class ExotelAIAssistController extends EventEmitter {
|
|
|
21042
21040
|
if (hashChanged) {
|
|
21043
21041
|
this._clearReconnectTimer();
|
|
21044
21042
|
this.connectionEstablished = false;
|
|
21045
|
-
this._acknowledged = false;
|
|
21046
21043
|
this.reconnectAttempt = 0;
|
|
21047
21044
|
// Tear down the current transport and start fresh with the new params.
|
|
21048
21045
|
(_a = this.transport) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
@@ -21123,7 +21120,6 @@ class ExotelAIAssistController extends EventEmitter {
|
|
|
21123
21120
|
var _a;
|
|
21124
21121
|
if (this.destroyed) return;
|
|
21125
21122
|
this.connectionEstablished = false;
|
|
21126
|
-
this._acknowledged = false;
|
|
21127
21123
|
(_a = this.transport) === null || _a === void 0 ? void 0 : _a.connect(Utils.buildWsUrl(this.params), this.params.authToken);
|
|
21128
21124
|
}, delay);
|
|
21129
21125
|
}
|
|
@@ -21154,10 +21150,6 @@ class ExotelAIAssistController extends EventEmitter {
|
|
|
21154
21150
|
this.emit("error", err);
|
|
21155
21151
|
return;
|
|
21156
21152
|
}
|
|
21157
|
-
if (!this._acknowledged && msgType === "ack") {
|
|
21158
|
-
this._acknowledged = true;
|
|
21159
|
-
this.emit("acknowledged");
|
|
21160
|
-
}
|
|
21161
21153
|
if (parsed.config) {
|
|
21162
21154
|
this.emit("botConfig", parsed.config);
|
|
21163
21155
|
}
|
|
@@ -21211,19 +21203,15 @@ ExotelAIAssistController.RECONNECT_BASE_MS = 3000;
|
|
|
21211
21203
|
function useExotelAIAssist(params) {
|
|
21212
21204
|
const controllerRef = reactExports.useRef(null);
|
|
21213
21205
|
const [status, setStatus] = reactExports.useState("idle");
|
|
21214
|
-
const [isAcknowledged, setIsAcknowledged] = reactExports.useState(false);
|
|
21215
21206
|
const [suggestions, setSuggestions] = reactExports.useState([]);
|
|
21216
21207
|
const [transcripts, setTranscripts] = reactExports.useState([]);
|
|
21217
21208
|
const [sentiment, setSentiment] = reactExports.useState(null);
|
|
21218
21209
|
const [botConfig, setBotConfig] = reactExports.useState(null);
|
|
21219
21210
|
const [lastError, setLastError] = reactExports.useState(null);
|
|
21220
21211
|
const paramHash = Utils.hash(params);
|
|
21221
|
-
console.log("params", params);
|
|
21222
|
-
console.log("paramHash", paramHash);
|
|
21223
21212
|
reactExports.useEffect(() => {
|
|
21224
21213
|
// Clear all stale state from the previous session before connecting.
|
|
21225
21214
|
setStatus("idle");
|
|
21226
|
-
setIsAcknowledged(false);
|
|
21227
21215
|
setSuggestions([]);
|
|
21228
21216
|
setTranscripts([]);
|
|
21229
21217
|
setSentiment(null);
|
|
@@ -21232,7 +21220,6 @@ function useExotelAIAssist(params) {
|
|
|
21232
21220
|
const ctrl = new ExotelAIAssistController(params);
|
|
21233
21221
|
controllerRef.current = ctrl;
|
|
21234
21222
|
ctrl.on("statusChange", setStatus);
|
|
21235
|
-
ctrl.on("acknowledged", () => setIsAcknowledged(true));
|
|
21236
21223
|
ctrl.on("botConfig", setBotConfig);
|
|
21237
21224
|
ctrl.on("suggestion", s => setSuggestions(prev => [...prev, s].slice(-50)));
|
|
21238
21225
|
ctrl.on("sentiment", setSentiment);
|
|
@@ -21263,7 +21250,6 @@ function useExotelAIAssist(params) {
|
|
|
21263
21250
|
}, []);
|
|
21264
21251
|
return {
|
|
21265
21252
|
status,
|
|
21266
|
-
isAcknowledged,
|
|
21267
21253
|
suggestions,
|
|
21268
21254
|
transcripts,
|
|
21269
21255
|
sentiment,
|
package/dist/react/index.js
CHANGED
|
@@ -6299,7 +6299,6 @@ class ExotelAIAssistController extends EventEmitter {
|
|
|
6299
6299
|
// connectionEstablished === false → connection never opened → retry
|
|
6300
6300
|
// connectionEstablished === true → server ended a live connection → destroy
|
|
6301
6301
|
this.connectionEstablished = false;
|
|
6302
|
-
this._acknowledged = false;
|
|
6303
6302
|
this.reconnectAttempt = 0;
|
|
6304
6303
|
this.reconnectTimer = null;
|
|
6305
6304
|
this.params = Object.assign({}, params);
|
|
@@ -6308,7 +6307,6 @@ class ExotelAIAssistController extends EventEmitter {
|
|
|
6308
6307
|
if (this.destroyed) return;
|
|
6309
6308
|
this._clearReconnectTimer();
|
|
6310
6309
|
this.connectionEstablished = false;
|
|
6311
|
-
this._acknowledged = false;
|
|
6312
6310
|
this.reconnectAttempt = 0;
|
|
6313
6311
|
this._setStatus("connecting");
|
|
6314
6312
|
this._ensureTransport();
|
|
@@ -6328,7 +6326,6 @@ class ExotelAIAssistController extends EventEmitter {
|
|
|
6328
6326
|
if (hashChanged) {
|
|
6329
6327
|
this._clearReconnectTimer();
|
|
6330
6328
|
this.connectionEstablished = false;
|
|
6331
|
-
this._acknowledged = false;
|
|
6332
6329
|
this.reconnectAttempt = 0;
|
|
6333
6330
|
// Tear down the current transport and start fresh with the new params.
|
|
6334
6331
|
(_a = this.transport) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
@@ -6409,7 +6406,6 @@ class ExotelAIAssistController extends EventEmitter {
|
|
|
6409
6406
|
var _a;
|
|
6410
6407
|
if (this.destroyed) return;
|
|
6411
6408
|
this.connectionEstablished = false;
|
|
6412
|
-
this._acknowledged = false;
|
|
6413
6409
|
(_a = this.transport) === null || _a === void 0 ? void 0 : _a.connect(Utils.buildWsUrl(this.params), this.params.authToken);
|
|
6414
6410
|
}, delay);
|
|
6415
6411
|
}
|
|
@@ -6440,10 +6436,6 @@ class ExotelAIAssistController extends EventEmitter {
|
|
|
6440
6436
|
this.emit("error", err);
|
|
6441
6437
|
return;
|
|
6442
6438
|
}
|
|
6443
|
-
if (!this._acknowledged && msgType === "ack") {
|
|
6444
|
-
this._acknowledged = true;
|
|
6445
|
-
this.emit("acknowledged");
|
|
6446
|
-
}
|
|
6447
6439
|
if (parsed.config) {
|
|
6448
6440
|
this.emit("botConfig", parsed.config);
|
|
6449
6441
|
}
|
|
@@ -6497,19 +6489,15 @@ ExotelAIAssistController.RECONNECT_BASE_MS = 3000;
|
|
|
6497
6489
|
function useExotelAIAssist(params) {
|
|
6498
6490
|
const controllerRef = React.useRef(null);
|
|
6499
6491
|
const [status, setStatus] = React.useState("idle");
|
|
6500
|
-
const [isAcknowledged, setIsAcknowledged] = React.useState(false);
|
|
6501
6492
|
const [suggestions, setSuggestions] = React.useState([]);
|
|
6502
6493
|
const [transcripts, setTranscripts] = React.useState([]);
|
|
6503
6494
|
const [sentiment, setSentiment] = React.useState(null);
|
|
6504
6495
|
const [botConfig, setBotConfig] = React.useState(null);
|
|
6505
6496
|
const [lastError, setLastError] = React.useState(null);
|
|
6506
6497
|
const paramHash = Utils.hash(params);
|
|
6507
|
-
console.log("params", params);
|
|
6508
|
-
console.log("paramHash", paramHash);
|
|
6509
6498
|
React.useEffect(() => {
|
|
6510
6499
|
// Clear all stale state from the previous session before connecting.
|
|
6511
6500
|
setStatus("idle");
|
|
6512
|
-
setIsAcknowledged(false);
|
|
6513
6501
|
setSuggestions([]);
|
|
6514
6502
|
setTranscripts([]);
|
|
6515
6503
|
setSentiment(null);
|
|
@@ -6518,7 +6506,6 @@ function useExotelAIAssist(params) {
|
|
|
6518
6506
|
const ctrl = new ExotelAIAssistController(params);
|
|
6519
6507
|
controllerRef.current = ctrl;
|
|
6520
6508
|
ctrl.on("statusChange", setStatus);
|
|
6521
|
-
ctrl.on("acknowledged", () => setIsAcknowledged(true));
|
|
6522
6509
|
ctrl.on("botConfig", setBotConfig);
|
|
6523
6510
|
ctrl.on("suggestion", s => setSuggestions(prev => [...prev, s].slice(-50)));
|
|
6524
6511
|
ctrl.on("sentiment", setSentiment);
|
|
@@ -6549,7 +6536,6 @@ function useExotelAIAssist(params) {
|
|
|
6549
6536
|
}, []);
|
|
6550
6537
|
return {
|
|
6551
6538
|
status,
|
|
6552
|
-
isAcknowledged,
|
|
6553
6539
|
suggestions,
|
|
6554
6540
|
transcripts,
|
|
6555
6541
|
sentiment,
|
package/dist/types/index.d.ts
CHANGED
|
@@ -72,8 +72,6 @@ export interface ControllerEvents {
|
|
|
72
72
|
onCallStart: () => void;
|
|
73
73
|
onCallEnd: () => void;
|
|
74
74
|
statusChange: (status: ConnectionStatus) => void;
|
|
75
|
-
/** Fired once when the server sends its first valid payload after auth. */
|
|
76
|
-
acknowledged: () => void;
|
|
77
75
|
error: (err: Error) => void;
|
|
78
76
|
raw: (data: unknown) => void;
|
|
79
77
|
}
|
package/package.json
CHANGED