@telnyx/ai-agent-lib 0.2.13 → 0.3.0-beta.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.
package/dist/client.d.ts CHANGED
@@ -4,6 +4,7 @@ import type { AIAgentEvents, TranscriptItem, VADOptions } from "./types";
4
4
  export type TelnyxAIAgentConstructorParams = {
5
5
  agentId: string;
6
6
  versionId?: string;
7
+ conversationId?: string;
7
8
  environment?: "production" | "development";
8
9
  debug?: boolean;
9
10
  trickleIce?: boolean;
@@ -17,6 +18,7 @@ export declare class TelnyxAIAgent extends EventEmitter<AIAgentEvents> {
17
18
  private transcription;
18
19
  agentId: string;
19
20
  versionId: string;
21
+ conversationId?: string;
20
22
  debug: boolean;
21
23
  private audioStreamMonitor;
22
24
  activeCall: Call | null;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import ht, { useReducer as kn, useEffect as pe, useDebugValue as In, useCallback as En, useContext as Gt, createContext as Ht, useState as Tn } from "react";
1
+ import ht, { useReducer as In, useEffect as pe, useDebugValue as kn, useCallback as En, useContext as Gt, createContext as Ht, useState as Tn } from "react";
2
2
  function De(t, e) {
3
3
  var n = {};
4
4
  for (var i in t) Object.prototype.hasOwnProperty.call(t, i) && e.indexOf(i) < 0 && (n[i] = t[i]);
@@ -159,9 +159,9 @@ var Mn = zt((function(t) {
159
159
  var C = _[g];
160
160
  return C || (C = _[g] = new w(g, b.getLevel(), b.methodFactory)), C;
161
161
  };
162
- var k = typeof window !== s ? window.log : void 0;
162
+ var I = typeof window !== s ? window.log : void 0;
163
163
  return b.noConflict = function() {
164
- return typeof window !== s && window.log === b && (window.log = k), b;
164
+ return typeof window !== s && window.log === b && (window.log = I), b;
165
165
  }, b.getLoggers = function() {
166
166
  return _;
167
167
  }, b.default = b, b;
@@ -199,7 +199,7 @@ const Le = (t) => {
199
199
  if (s === null) return e !== null && (n.node_id = e), { result: n };
200
200
  const { code: a = null, node_id: o = null, result: l = null } = s;
201
201
  return a && a !== "200" ? { error: s } : l ? Jt(l, o) : { result: s };
202
- }, Kt = (t, e) => Math.floor(Math.random() * (e - t + 1) + t), Ue = ({ login: t, passwd: e, password: n, login_token: i }) => !!(t && (e || n) || i), ke = ({ anonymous_login: t }) => !!t && !!t.target_id && !!t.target_type, pt = (t) => {
202
+ }, Kt = (t, e) => Math.floor(Math.random() * (e - t + 1) + t), Ue = ({ login: t, passwd: e, password: n, login_token: i }) => !!(t && (e || n) || i), Ie = ({ anonymous_login: t }) => !!t && !!t.target_id && !!t.target_type, pt = (t) => {
203
203
  var e, n, i, s, a, o;
204
204
  let l = "", u = "";
205
205
  return !((n = (e = t?.result) === null || e === void 0 ? void 0 : e.params) === null || n === void 0) && n.state && (l = (s = (i = t?.result) === null || i === void 0 ? void 0 : i.params) === null || s === void 0 ? void 0 : s.state), !((a = t?.params) === null || a === void 0) && a.state && (u = (o = t?.params) === null || o === void 0 ? void 0 : o.state), l || u;
@@ -218,7 +218,7 @@ const Nn = (t, e) => {
218
218
  }), e);
219
219
  };
220
220
  }, ft = "telnyx-voice-sdk-id";
221
- function Ie() {
221
+ function ke() {
222
222
  return sessionStorage.getItem(ft);
223
223
  }
224
224
  var K, le, V;
@@ -301,7 +301,7 @@ class St {
301
301
  }
302
302
  connect() {
303
303
  const e = new URL(this._host);
304
- let n = Ie();
304
+ let n = ke();
305
305
  this.session.options.rtcIp && this.session.options.rtcPort && (n = null, this._useCanaryRtcServer = !1, e.searchParams.set("rtc_ip", this.session.options.rtcIp), e.searchParams.set("rtc_port", this.session.options.rtcPort.toString())), n && e.searchParams.set("voice_sdk_id", n), this._useCanaryRtcServer && (e.searchParams.set("canary", "true"), n && !this._hasCanaryBeenUsed && (e.searchParams.delete("voice_sdk_id"), m.debug("first canary connection. Refreshing voice_sdk_id")), this._hasCanaryBeenUsed = !0), this._wsClient = new $n(e.toString()), this._wsClient.onopen = (i) => j(x.SocketOpen, i, this.session.uuid), this._wsClient.onclose = (i) => j(x.SocketClose, i, this.session.uuid), this._wsClient.onerror = (i) => j(x.SocketError, { error: i, sessionId: this.session.sessionid }, this.session.uuid), this._wsClient.onmessage = (i) => {
306
306
  var s, a;
307
307
  const o = Yt(i.data);
@@ -374,7 +374,7 @@ class Hn {
374
374
  this.pendingRequestId = null, this.onSocketMessage = (n) => P(this, void 0, void 0, (function* () {
375
375
  n.id === this.pendingRequestId && this.gatewayStateTask.resolve(pt(n));
376
376
  })), this.getIsRegistered = () => P(this, void 0, void 0, (function* () {
377
- const n = new Zt(Ie());
377
+ const n = new Zt(ke());
378
378
  this.pendingRequestId = n.request.id, this.gatewayStateTask = bt({}), this.session.execute(n);
379
379
  const i = yield this.gatewayStateTask.promise;
380
380
  return !!i && [te.REGISTER, te.REGED].includes(i);
@@ -434,7 +434,7 @@ class Ze extends Z {
434
434
  return V.Modify;
435
435
  }
436
436
  }
437
- class kt extends Z {
437
+ class It extends Z {
438
438
  toString() {
439
439
  return V.Info;
440
440
  }
@@ -489,7 +489,7 @@ class Zn {
489
489
  this._idle ? this._executeQueue.push({ msg: e }) : this.connection.sendRawText(e);
490
490
  }
491
491
  validateOptions() {
492
- return Ue(this.options) || ke(this.options);
492
+ return Ue(this.options) || Ie(this.options);
493
493
  }
494
494
  broadcast(e) {
495
495
  }
@@ -516,7 +516,7 @@ class Zn {
516
516
  return P(this, void 0, void 0, (function* () {
517
517
  if (this.connection && this.connection.isAlive) {
518
518
  if (e && (e.login !== void 0 && (this.options.login = e.login), e.password !== void 0 && (this.options.password = e.password), e.passwd !== void 0 && (this.options.passwd = e.passwd), e.login_token !== void 0 && (this.options.login_token = e.login_token), e.userVariables !== void 0 && (this.options.userVariables = e.userVariables), e.anonymous_login !== void 0 && (this.options.anonymous_login = e.anonymous_login)), Ue(this.options)) return this._login({ type: "login", onSuccess: n, onError: i });
519
- if (ke(this.options)) return this._login({ type: "anonymous_login", onSuccess: n, onError: i });
519
+ if (Ie(this.options)) return this._login({ type: "anonymous_login", onSuccess: n, onError: i });
520
520
  {
521
521
  const s = "Invalid login options provided for authentication.";
522
522
  return m.error(s), void j(x.Error, { error: new Error(s), type: Un.invalidCredentialsOptions, sessionId: this.sessionid }, this.uuid);
@@ -527,7 +527,7 @@ class Zn {
527
527
  _login({ type: e, onSuccess: n, onError: i }) {
528
528
  return P(this, void 0, void 0, (function* () {
529
529
  let s;
530
- s = e === "login" ? new Wn(this.options.login, this.options.password || this.options.passwd, this.options.login_token, this.sessionid, this.options.userVariables, !!Ie()) : new Xn({ target_id: this.options.anonymous_login.target_id, target_type: this.options.anonymous_login.target_type, target_version_id: this.options.anonymous_login.target_version_id, sessionId: this.sessionid, userVariables: this.options.userVariables, reconnection: !!Ie() });
530
+ s = e === "login" ? new Wn(this.options.login, this.options.password || this.options.passwd, this.options.login_token, this.sessionid, this.options.userVariables, !!ke()) : new Xn({ target_id: this.options.anonymous_login.target_id, target_type: this.options.anonymous_login.target_type, target_version_id: this.options.anonymous_login.target_version_id, sessionId: this.sessionid, userVariables: this.options.userVariables, reconnection: !!ke() });
531
531
  const a = yield this.execute(s).catch(((o) => {
532
532
  this._handleLoginError(o), i && i(o);
533
533
  }));
@@ -569,7 +569,7 @@ class Zn {
569
569
  this._idle = !0, clearTimeout(this._keepAliveTimeout), this.connection && this.connection.close();
570
570
  }
571
571
  _resetKeepAlive() {
572
- this._pong === !1 && (m.warn("No ping/pong received, forcing PING ACK to keep alive"), this.execute(new en(Ie()))), clearTimeout(this._keepAliveTimeout), this._triggerKeepAliveTimeoutCheck();
572
+ this._pong === !1 && (m.warn("No ping/pong received, forcing PING ACK to keep alive"), this.execute(new en(ke()))), clearTimeout(this._keepAliveTimeout), this._triggerKeepAliveTimeoutCheck();
573
573
  }
574
574
  _triggerKeepAliveTimeoutCheck() {
575
575
  this._pong = !1, this._keepAliveTimeout = setTimeout((() => this._resetKeepAlive()), 35e3);
@@ -656,7 +656,7 @@ const je = (t) => navigator.mediaDevices.getUserMedia(t), fe = (t) => t && t ins
656
656
  }));
657
657
  }
658
658
  return n;
659
- })), It = [[320, 240], [640, 360], [640, 480], [1280, 720], [1920, 1080]], Fe = (t, e, n) => P(void 0, void 0, void 0, (function* () {
659
+ })), kt = [[320, 240], [640, 360], [640, 480], [1280, 720], [1920, 1080]], Fe = (t, e, n) => P(void 0, void 0, void 0, (function* () {
660
660
  const i = yield Ce(n, !0);
661
661
  for (let s = 0; s < i.length; s++) {
662
662
  const { deviceId: a, label: o } = i[s];
@@ -795,17 +795,17 @@ var Oe, on = zt((function(t, e) {
795
795
  return r._maxListeners === void 0 ? s.defaultMaxListeners : r._maxListeners;
796
796
  }
797
797
  function o(r, c, h, v) {
798
- var S, E, I;
798
+ var S, E, k;
799
799
  if (typeof h != "function") throw new TypeError('"listener" argument must be a function');
800
- if ((E = r._events) ? (E.newListener && (r.emit("newListener", c, h.listener ? h.listener : h), E = r._events), I = E[c]) : (E = r._events = new i(), r._eventsCount = 0), I) {
801
- if (typeof I == "function" ? I = E[c] = v ? [h, I] : [I, h] : v ? I.unshift(h) : I.push(h), !I.warned && (S = a(r)) && 0 < S && I.length > S) {
802
- I.warned = !0;
803
- var R = new Error("Possible EventEmitter memory leak detected. " + I.length + " " + c + " listeners added. Use emitter.setMaxListeners() to increase limit");
804
- R.name = "MaxListenersExceededWarning", R.emitter = r, R.type = c, R.count = I.length, (function($) {
800
+ if ((E = r._events) ? (E.newListener && (r.emit("newListener", c, h.listener ? h.listener : h), E = r._events), k = E[c]) : (E = r._events = new i(), r._eventsCount = 0), k) {
801
+ if (typeof k == "function" ? k = E[c] = v ? [h, k] : [k, h] : v ? k.unshift(h) : k.push(h), !k.warned && (S = a(r)) && 0 < S && k.length > S) {
802
+ k.warned = !0;
803
+ var R = new Error("Possible EventEmitter memory leak detected. " + k.length + " " + c + " listeners added. Use emitter.setMaxListeners() to increase limit");
804
+ R.name = "MaxListenersExceededWarning", R.emitter = r, R.type = c, R.count = k.length, (function($) {
805
805
  typeof console.warn == "function" ? console.warn($) : console.log($);
806
806
  })(R);
807
807
  }
808
- } else I = E[c] = h, ++r._eventsCount;
808
+ } else k = E[c] = h, ++r._eventsCount;
809
809
  return r;
810
810
  }
811
811
  function l(r, c, h) {
@@ -836,8 +836,8 @@ var Oe, on = zt((function(t, e) {
836
836
  }, s.prototype.getMaxListeners = function() {
837
837
  return a(this);
838
838
  }, s.prototype.emit = function(r) {
839
- var c, h, v, S, E, I, R, $ = r === "error";
840
- if (I = this._events) $ = $ && I.error == null;
839
+ var c, h, v, S, E, k, R, $ = r === "error";
840
+ if (k = this._events) $ = $ && k.error == null;
841
841
  else if (!$) return !1;
842
842
  if (R = this.domain, $) {
843
843
  if (c = arguments[1], !R) {
@@ -847,7 +847,7 @@ var Oe, on = zt((function(t, e) {
847
847
  }
848
848
  return c || (c = new Error('Uncaught, unspecified "error" event')), c.domainEmitter = this, c.domain = R, c.domainThrown = !1, R.emit("error", c), !1;
849
849
  }
850
- if (!(h = I[r])) return !1;
850
+ if (!(h = k[r])) return !1;
851
851
  var ne = typeof h == "function";
852
852
  switch (v = arguments.length) {
853
853
  case 1:
@@ -893,14 +893,14 @@ var Oe, on = zt((function(t, e) {
893
893
  if (typeof c != "function") throw new TypeError('"listener" argument must be a function');
894
894
  return this.prependListener(r, l(this, r, c)), this;
895
895
  }, s.prototype.removeListener = function(r, c) {
896
- var h, v, S, E, I;
896
+ var h, v, S, E, k;
897
897
  if (typeof c != "function") throw new TypeError('"listener" argument must be a function');
898
898
  if (!(v = this._events)) return this;
899
899
  if (!(h = v[r])) return this;
900
900
  if (h === c || h.listener && h.listener === c) --this._eventsCount == 0 ? this._events = new i() : (delete v[r], v.removeListener && this.emit("removeListener", r, h.listener || c));
901
901
  else if (typeof h != "function") {
902
902
  for (S = -1, E = h.length; 0 < E--; ) if (h[E] === c || h[E].listener && h[E].listener === c) {
903
- I = h[E].listener, S = E;
903
+ k = h[E].listener, S = E;
904
904
  break;
905
905
  }
906
906
  if (0 > S) return this;
@@ -911,7 +911,7 @@ var Oe, on = zt((function(t, e) {
911
911
  for (var ee = $, ne = ee + 1, G = R.length; ne < G; ee += 1, ne += 1) R[ee] = R[ne];
912
912
  R.pop();
913
913
  })(h, S);
914
- v.removeListener && this.emit("removeListener", r, I || c);
914
+ v.removeListener && this.emit("removeListener", r, k || c);
915
915
  }
916
916
  return this;
917
917
  }, s.prototype.removeAllListeners = function(r) {
@@ -930,7 +930,7 @@ var Oe, on = zt((function(t, e) {
930
930
  }, s.prototype.listeners = function(r) {
931
931
  var c, h, v = this._events;
932
932
  return v ? h = (c = v[r]) ? typeof c == "function" ? [c.listener || c] : (function(S) {
933
- for (var E = Array(S.length), I = 0; I < E.length; ++I) E[I] = S[I].listener || S[I];
933
+ for (var E = Array(S.length), k = 0; k < E.length; ++k) E[k] = S[k].listener || S[k];
934
934
  return E;
935
935
  })(c) : [] : h = [], h;
936
936
  }, s.listenerCount = function(r, c) {
@@ -943,7 +943,7 @@ var Oe, on = zt((function(t, e) {
943
943
  if (!p && !(p = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto < "u" && typeof msCrypto.getRandomValues == "function" && msCrypto.getRandomValues.bind(msCrypto))) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
944
944
  return p(f);
945
945
  }
946
- for (var b = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i, _ = [], k = 0; 256 > k; ++k) _.push((k + 256).toString(16).substr(1));
946
+ for (var b = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i, _ = [], I = 0; 256 > I; ++I) _.push((I + 256).toString(16).substr(1));
947
947
  function g(r) {
948
948
  var c = 1 < arguments.length && arguments[1] !== void 0 ? arguments[1] : 0, h = (_[r[c + 0]] + _[r[c + 1]] + _[r[c + 2]] + _[r[c + 3]] + "-" + _[r[c + 4]] + _[r[c + 5]] + "-" + _[r[c + 6]] + _[r[c + 7]] + "-" + _[r[c + 8]] + _[r[c + 9]] + "-" + _[r[c + 10]] + _[r[c + 11]] + _[r[c + 12]] + _[r[c + 13]] + _[r[c + 14]] + _[r[c + 15]]).toLowerCase();
949
949
  if (!(function(v) {
@@ -970,8 +970,8 @@ var Oe, on = zt((function(t, e) {
970
970
  }
971
971
  function A(r, c, h) {
972
972
  return 8 * (function(v, S, E) {
973
- const I = v[E], R = S ? S[E] : null;
974
- return I === null || R === null ? null : (I - R) / (v.timestamp - S.timestamp) * 1e3;
973
+ const k = v[E], R = S ? S[E] : null;
974
+ return k === null || R === null ? null : (k - R) / (v.timestamp - S.timestamp) * 1e3;
975
975
  })(r, c, h);
976
976
  }
977
977
  function O(r) {
@@ -987,18 +987,18 @@ var Oe, on = zt((function(t, e) {
987
987
  h.remote && (v.remote = { audio: { inbound: [], outbound: [] }, video: { inbound: [], outbound: [] } });
988
988
  for (const S of r.values()) switch (S.type) {
989
989
  case "outbound-rtp": {
990
- const E = S.mediaType || S.kind, I = {};
990
+ const E = S.mediaType || S.kind, k = {};
991
991
  let R = {};
992
992
  if (!["audio", "video"].includes(E)) continue;
993
993
  if (S.codecId) {
994
994
  const $ = r.get(S.codecId);
995
- $ && (I.clockRate = $.clockRate, I.mimeType = $.mimeType, I.payloadType = $.payloadType);
995
+ $ && (k.clockRate = $.clockRate, k.mimeType = $.mimeType, k.payloadType = $.payloadType);
996
996
  }
997
- R = r.get(S.mediaSourceId) || r.get(S.trackId) || {}, v[E].outbound.push({ ...S, ...I, track: { ...R } });
997
+ R = r.get(S.mediaSourceId) || r.get(S.trackId) || {}, v[E].outbound.push({ ...S, ...k, track: { ...R } });
998
998
  break;
999
999
  }
1000
1000
  case "inbound-rtp": {
1001
- let E = S.mediaType || S.kind, I = {};
1001
+ let E = S.mediaType || S.kind, k = {};
1002
1002
  const R = {};
1003
1003
  if (!["audio", "video"].includes(E)) if (S.id.includes("Video")) E = "video";
1004
1004
  else {
@@ -1016,7 +1016,7 @@ var Oe, on = zt((function(t, e) {
1016
1016
  v.connection = T(ee, r);
1017
1017
  }
1018
1018
  }
1019
- I = r.get(S.mediaSourceId) || r.get(S.trackId) || {}, v[E].inbound.push({ ...S, ...R, track: { ...I } });
1019
+ k = r.get(S.mediaSourceId) || r.get(S.trackId) || {}, v[E].inbound.push({ ...S, ...R, track: { ...k } });
1020
1020
  break;
1021
1021
  }
1022
1022
  case "peer-connection":
@@ -1025,7 +1025,7 @@ var Oe, on = zt((function(t, e) {
1025
1025
  case "remote-inbound-rtp": {
1026
1026
  if (!h.remote) break;
1027
1027
  let E = S.mediaType || S.kind;
1028
- const I = {};
1028
+ const k = {};
1029
1029
  if (!["audio", "video"].includes(E)) if (S.id.includes("Video")) E = "video";
1030
1030
  else {
1031
1031
  if (!S.id.includes("Audio")) continue;
@@ -1033,7 +1033,7 @@ var Oe, on = zt((function(t, e) {
1033
1033
  }
1034
1034
  if (S.codecId) {
1035
1035
  const R = r.get(S.codecId);
1036
- R && (I.clockRate = R.clockRate, I.mimeType = R.mimeType, I.payloadType = R.payloadType);
1036
+ R && (k.clockRate = R.clockRate, k.mimeType = R.mimeType, k.payloadType = R.payloadType);
1037
1037
  }
1038
1038
  if (!v.connection.id && S.transportId) {
1039
1039
  const R = r.get(S.transportId);
@@ -1042,35 +1042,35 @@ var Oe, on = zt((function(t, e) {
1042
1042
  v.connection = T($, r);
1043
1043
  }
1044
1044
  }
1045
- v.remote[E].inbound.push({ ...S, ...I });
1045
+ v.remote[E].inbound.push({ ...S, ...k });
1046
1046
  break;
1047
1047
  }
1048
1048
  case "remote-outbound-rtp": {
1049
1049
  if (!h.remote) break;
1050
- const E = S.mediaType || S.kind, I = {};
1050
+ const E = S.mediaType || S.kind, k = {};
1051
1051
  if (!["audio", "video"].includes(E)) continue;
1052
1052
  if (S.codecId) {
1053
1053
  const R = r.get(S.codecId);
1054
- R && (I.clockRate = R.clockRate, I.mimeType = R.mimeType, I.payloadType = R.payloadType);
1054
+ R && (k.clockRate = R.clockRate, k.mimeType = R.mimeType, k.payloadType = R.payloadType);
1055
1055
  }
1056
- v.remote[E].outbound.push({ ...S, ...I });
1056
+ v.remote[E].outbound.push({ ...S, ...k });
1057
1057
  break;
1058
1058
  }
1059
1059
  }
1060
1060
  if (!v.connection.id) for (const S of r.values()) S.type === "candidate-pair" && S.nominated && S.state === "succeeded" && (v.connection = T(S, r));
1061
1061
  return v = (function(S, E) {
1062
- return E && (S.audio.inbound.map(((I) => {
1063
- let R = E.audio.inbound.find((($) => $.id === I.id));
1064
- I.bitrate = A(I, R, "bytesReceived"), I.packetRate = A(I, R, "packetsReceived");
1065
- })), S.audio.outbound.map(((I) => {
1066
- let R = E.audio.outbound.find((($) => $.id === I.id));
1067
- I.bitrate = A(I, R, "bytesSent"), I.packetRate = A(I, R, "packetsSent");
1068
- })), S.video.inbound.map(((I) => {
1069
- let R = E.video.inbound.find((($) => $.id === I.id));
1070
- I.bitrate = A(I, R, "bytesReceived"), I.packetRate = A(I, R, "packetsReceived");
1071
- })), S.video.outbound.map(((I) => {
1072
- let R = E.video.outbound.find((($) => $.id === I.id));
1073
- I.bitrate = A(I, R, "bytesSent"), I.packetRate = A(I, R, "packetsSent");
1062
+ return E && (S.audio.inbound.map(((k) => {
1063
+ let R = E.audio.inbound.find((($) => $.id === k.id));
1064
+ k.bitrate = A(k, R, "bytesReceived"), k.packetRate = A(k, R, "packetsReceived");
1065
+ })), S.audio.outbound.map(((k) => {
1066
+ let R = E.audio.outbound.find((($) => $.id === k.id));
1067
+ k.bitrate = A(k, R, "bytesSent"), k.packetRate = A(k, R, "packetsSent");
1068
+ })), S.video.inbound.map(((k) => {
1069
+ let R = E.video.inbound.find((($) => $.id === k.id));
1070
+ k.bitrate = A(k, R, "bytesReceived"), k.packetRate = A(k, R, "packetsReceived");
1071
+ })), S.video.outbound.map(((k) => {
1072
+ let R = E.video.outbound.find((($) => $.id === k.id));
1073
+ k.bitrate = A(k, R, "bytesSent"), k.packetRate = A(k, R, "packetsSent");
1074
1074
  }))), S;
1075
1075
  })(v, c), v;
1076
1076
  }
@@ -1092,15 +1092,15 @@ var Oe, on = zt((function(t, e) {
1092
1092
  if (this.isEdge) throw new Error("Can't monitor peers in Edge at this time.");
1093
1093
  if (this.peersToMonitor[h]) {
1094
1094
  if (v && v in this.peersToMonitor[h]) throw new Error(`We are already monitoring connection with id ${v}.`);
1095
- for (let I in this.peersToMonitor[h]) {
1096
- const R = this.peersToMonitor[h][I];
1095
+ for (let k in this.peersToMonitor[h]) {
1096
+ const R = this.peersToMonitor[h][k];
1097
1097
  if (R.pc === c) throw new Error(`We are already monitoring peer with id ${h}.`);
1098
1098
  R.pc.connectionState === "closed" && this.removeConnection({ pc: R.pc });
1099
1099
  }
1100
1100
  }
1101
1101
  const E = c.getConfiguration();
1102
- return E.iceServers && E.iceServers.forEach((function(I) {
1103
- delete I.credential;
1102
+ return E.iceServers && E.iceServers.forEach((function(k) {
1103
+ delete k.credential;
1104
1104
  })), v || (v = C()), this.emitEvent({ event: "addConnection", tag: "peer", peerId: h, connectionId: v, data: { options: r, peerConfiguration: E } }), this.monitorPeer({ peerId: h, connectionId: v, pc: c, remote: S }), { connectionId: v };
1105
1105
  }
1106
1106
  getTimeline(r) {
@@ -1182,9 +1182,9 @@ var Oe, on = zt((function(t, e) {
1182
1182
  } else c = this.peersToMonitor;
1183
1183
  let h = [];
1184
1184
  for (const v in c) for (const S in c[v]) {
1185
- const E = c[v][S], I = E.pc;
1186
- if (I && !this.checkIfConnectionIsClosed(v, S, I)) try {
1187
- const R = this.getTimestamp(), $ = I.getStats(null);
1185
+ const E = c[v][S], k = E.pc;
1186
+ if (k && !this.checkIfConnectionIsClosed(v, S, k)) try {
1187
+ const R = this.getTimestamp(), $ = k.getStats(null);
1188
1188
  if ($) {
1189
1189
  const ee = await $, ne = this.getTimestamp(), G = O(ee), y = { remote: E.options.remote }, M = D(ee, E.stats.parsed, y), U = { event: "stats", tag: "stats", peerId: v, connectionId: S, timeTaken: ne - R, data: M };
1190
1190
  this.rawStats === !0 && (U.rawStats = ee), this.statsObject === !0 && (U.statsObject = G), this.filteredStats === !0 && (U.filteredStats = this.filteroutStats(G)), h.push(U), E.stats.parsed = M;
@@ -1241,8 +1241,8 @@ var Oe, on = zt((function(t, e) {
1241
1241
  }, track: (r, c, h, v) => {
1242
1242
  this.logger.debug(`[pc-event] track | peerId: ${r}`, v);
1243
1243
  const S = v.track, E = v.streams[0];
1244
- r in this.peersToMonitor && c in this.peersToMonitor[r] && (this.peersToMonitor[r][c].stream = E), this.addTrackEventListeners(S, c), this.emitEvent({ event: "ontrack", tag: "track", peerId: r, connectionId: c, data: { stream: E ? this.getStreamDetails(E) : null, track: S ? this.getMediaTrackDetails(S) : null, title: v.track.kind + ":" + v.track.id + " " + v.streams.map((function(I) {
1245
- return "stream:" + I.id;
1244
+ r in this.peersToMonitor && c in this.peersToMonitor[r] && (this.peersToMonitor[r][c].stream = E), this.addTrackEventListeners(S, c), this.emitEvent({ event: "ontrack", tag: "track", peerId: r, connectionId: c, data: { stream: E ? this.getStreamDetails(E) : null, track: S ? this.getMediaTrackDetails(S) : null, title: v.track.kind + ":" + v.track.id + " " + v.streams.map((function(k) {
1245
+ return "stream:" + k.id;
1246
1246
  })) } });
1247
1247
  }, signalingstatechange: (r, c, h) => {
1248
1248
  this.logger.debug(`[pc-event] signalingstatechange | peerId: ${r}`), this.emitEvent({ event: "onsignalingstatechange", tag: "connection", peerId: r, connectionId: c, data: { signalingState: h.signalingState, localDescription: h.localDescription, remoteDescription: h.remoteDescription } });
@@ -1397,8 +1397,8 @@ function ui(t, e) {
1397
1397
  let i = !1;
1398
1398
  const s = new oi({ getStatsInterval: 1e3, rawStats: !1, statsObject: !0, filteredStats: !1, remote: !0, debug: !1, logLevel: "warn" }), a = (o) => P(this, void 0, void 0, (function* () {
1399
1399
  o.event === "stats" && j(x.StatsFrame, (function({ data: l }) {
1400
- var u, d, p, f, w, b, _, k;
1401
- const { audio: g, remote: C } = l, { audio: T } = C, A = (d = (u = T.inbound[0]) === null || u === void 0 ? void 0 : u.jitter) !== null && d !== void 0 ? d : 1 / 0, O = (f = (p = T.inbound[0]) === null || p === void 0 ? void 0 : p.roundTripTime) !== null && f !== void 0 ? f : 1 / 0, D = (b = (w = g.inbound[0]) === null || w === void 0 ? void 0 : w.packetsReceived) !== null && b !== void 0 ? b : -1, q = (k = (_ = g.inbound[0]) === null || _ === void 0 ? void 0 : _.packetsLost) !== null && k !== void 0 ? k : -1, F = ri({ jitter: 1e3 * A, rtt: 1e3 * O, packetsLost: q, packetsReceived: D });
1400
+ var u, d, p, f, w, b, _, I;
1401
+ const { audio: g, remote: C } = l, { audio: T } = C, A = (d = (u = T.inbound[0]) === null || u === void 0 ? void 0 : u.jitter) !== null && d !== void 0 ? d : 1 / 0, O = (f = (p = T.inbound[0]) === null || p === void 0 ? void 0 : p.roundTripTime) !== null && f !== void 0 ? f : 1 / 0, D = (b = (w = g.inbound[0]) === null || w === void 0 ? void 0 : w.packetsReceived) !== null && b !== void 0 ? b : -1, q = (I = (_ = g.inbound[0]) === null || _ === void 0 ? void 0 : _.packetsLost) !== null && I !== void 0 ? I : -1, F = ri({ jitter: 1e3 * A, rtt: 1e3 * O, packetsLost: q, packetsReceived: D });
1402
1402
  return { jitter: A, rtt: O, mos: F, quality: ai(F), inboundAudio: g.inbound[0], outboundAudio: g.outbound[0], remoteInboundAudio: T.inbound[0], remoteOutboundAudio: T.outbound[0] };
1403
1403
  })(o), t.uuid), yield t.execute(new di(n, o));
1404
1404
  }));
@@ -1459,8 +1459,8 @@ class Ot {
1459
1459
  try {
1460
1460
  const b = yield d.getStats();
1461
1461
  b.forEach(((_) => {
1462
- _.type === "candidate-pair" && _.state === "succeeded" && (f.candidatePairState = _.state, b.forEach(((k) => {
1463
- k.type === "local-candidate" && k.id === _.localCandidateId && (f.localCandidateType = k.candidateType, f.selectedCandidatePair = f.selectedCandidatePair || { local: {}, remote: {} }, f.selectedCandidatePair.local = { address: k.address, port: k.port, protocol: k.protocol, candidateType: k.candidateType }), k.type === "remote-candidate" && k.id === _.remoteCandidateId && (f.remoteCandidateType = k.candidateType, f.selectedCandidatePair = f.selectedCandidatePair || { local: {}, remote: {} }, f.selectedCandidatePair.remote = { address: k.address, port: k.port, protocol: k.protocol, candidateType: k.candidateType });
1462
+ _.type === "candidate-pair" && _.state === "succeeded" && (f.candidatePairState = _.state, b.forEach(((I) => {
1463
+ I.type === "local-candidate" && I.id === _.localCandidateId && (f.localCandidateType = I.candidateType, f.selectedCandidatePair = f.selectedCandidatePair || { local: {}, remote: {} }, f.selectedCandidatePair.local = { address: I.address, port: I.port, protocol: I.protocol, candidateType: I.candidateType }), I.type === "remote-candidate" && I.id === _.remoteCandidateId && (f.remoteCandidateType = I.candidateType, f.selectedCandidatePair = f.selectedCandidatePair || { local: {}, remote: {} }, f.selectedCandidatePair.remote = { address: I.address, port: I.port, protocol: I.protocol, candidateType: I.candidateType });
1464
1464
  }))), _.type === "transport" && (f.dtlsCipher = _.dtlsCipher, f.srtpCipher = _.srtpCipher, f.tlsVersion = _.tlsVersion, _.dtlsState && (f.dtlsState = _.dtlsState));
1465
1465
  }));
1466
1466
  } catch (b) {
@@ -1691,8 +1691,8 @@ class an {
1691
1691
  }));
1692
1692
  }));
1693
1693
  };
1694
- const { iceServers: s, speaker: a, micId: o, micLabel: l, camId: u, camLabel: d, localElement: p, remoteElement: f, options: w, mediaConstraints: { audio: b, video: _ }, ringtoneFile: k, ringbackFile: g } = e;
1695
- this.options = Object.assign({}, jn, { audio: b, video: _, iceServers: n?.iceServers && Array.isArray(n.iceServers) ? n.iceServers : s, localElement: p, remoteElement: f, micId: o, micLabel: l, camId: u, camLabel: d, speakerId: a, ringtoneFile: k, ringbackFile: g, debug: w.debug, debugOutput: w.debugOutput, trickleIce: w.trickleIce, prefetchIceCandidates: w.prefetchIceCandidates, forceRelayCandidate: w.forceRelayCandidate, keepConnectionAliveOnSocketClose: w.keepConnectionAliveOnSocketClose, mutedMicOnStart: w.mutedMicOnStart }, n), this._onMediaError = this._onMediaError.bind(this), this._onPeerConnectionFailureError = this._onPeerConnectionFailureError.bind(this), this._onPeerConnectionSignalingStateClosed = this._onPeerConnectionSignalingStateClosed.bind(this), this._onTrickleIceSdp = this._onTrickleIceSdp.bind(this), this._registerPeerEvents = this._registerPeerEvents.bind(this), this._registerTrickleIcePeerEvents = this._registerTrickleIcePeerEvents.bind(this), this._init(), this.options && (this._ringtone = At(this.options.ringtoneFile, "_ringtone"), this._ringback = At(this.options.ringbackFile, "_ringback"));
1694
+ const { iceServers: s, speaker: a, micId: o, micLabel: l, camId: u, camLabel: d, localElement: p, remoteElement: f, options: w, mediaConstraints: { audio: b, video: _ }, ringtoneFile: I, ringbackFile: g } = e;
1695
+ this.options = Object.assign({}, jn, { audio: b, video: _, iceServers: n?.iceServers && Array.isArray(n.iceServers) ? n.iceServers : s, localElement: p, remoteElement: f, micId: o, micLabel: l, camId: u, camLabel: d, speakerId: a, ringtoneFile: I, ringbackFile: g, debug: w.debug, debugOutput: w.debugOutput, trickleIce: w.trickleIce, prefetchIceCandidates: w.prefetchIceCandidates, forceRelayCandidate: w.forceRelayCandidate, keepConnectionAliveOnSocketClose: w.keepConnectionAliveOnSocketClose, mutedMicOnStart: w.mutedMicOnStart }, n), this._onMediaError = this._onMediaError.bind(this), this._onPeerConnectionFailureError = this._onPeerConnectionFailureError.bind(this), this._onPeerConnectionSignalingStateClosed = this._onPeerConnectionSignalingStateClosed.bind(this), this._onTrickleIceSdp = this._onTrickleIceSdp.bind(this), this._registerPeerEvents = this._registerPeerEvents.bind(this), this._registerTrickleIcePeerEvents = this._registerTrickleIcePeerEvents.bind(this), this._init(), this.options && (this._ringtone = At(this.options.ringtoneFile, "_ringtone"), this._ringback = At(this.options.ringbackFile, "_ringback"));
1696
1696
  }
1697
1697
  get creatingPeer() {
1698
1698
  return this._creatingPeer;
@@ -1780,11 +1780,11 @@ class an {
1780
1780
  return this._execute(e).then(this._handleChangeHoldStateSuccess.bind(this)).catch(this._handleChangeHoldStateError.bind(this));
1781
1781
  }
1782
1782
  dtmf(e) {
1783
- const n = new kt({ sessid: this.session.sessionid, dtmf: e, dialogParams: this.options });
1783
+ const n = new It({ sessid: this.session.sessionid, dtmf: e, dialogParams: this.options });
1784
1784
  this._execute(n);
1785
1785
  }
1786
1786
  message(e, n) {
1787
- const i = { from: this.session.options.login, to: e, body: n }, s = new kt({ sessid: this.session.sessionid, msg: i, dialogParams: this.options });
1787
+ const i = { from: this.session.options.login, to: e, body: n }, s = new It({ sessid: this.session.sessionid, msg: i, dialogParams: this.options });
1788
1788
  this._execute(s);
1789
1789
  }
1790
1790
  muteAudio() {
@@ -2323,8 +2323,8 @@ class pi extends Zn {
2323
2323
  try {
2324
2324
  return yield ((n) => P(void 0, void 0, void 0, (function* () {
2325
2325
  const i = [], s = yield $e({ video: { deviceId: { exact: n } } }), a = s.getVideoTracks()[0];
2326
- for (let o = 0; o < It.length; o++) {
2327
- const [l, u] = It[o];
2326
+ for (let o = 0; o < kt.length; o++) {
2327
+ const [l, u] = kt[o];
2328
2328
  (yield a.applyConstraints({ width: { exact: l }, height: { exact: u } }).then((() => !0)).catch((() => !1))) && i.push({ resolution: `${l}x${u}`, width: l, height: u });
2329
2329
  }
2330
2330
  return Te(s), i;
@@ -2448,10 +2448,10 @@ class z {
2448
2448
  u && (F.id = u), o.telnyx_call_control_id && (F.telnyxCallControlId = o.telnyx_call_control_id), o.telnyx_session_id && (F.telnyxSessionId = o.telnyx_session_id), o.telnyx_leg_id && (F.telnyxLegId = o.telnyx_leg_id), o.client_state && (F.clientState = o.client_state), o.dialogParams && o.dialogParams.custom_headers && o.dialogParams.custom_headers.length && (F.customHeaders = o.dialogParams.custom_headers);
2449
2449
  const L = new he(i, F, g);
2450
2450
  return L.nodeId = this.nodeId, L;
2451
- }, _ = new Zt(l), k = new en(l);
2451
+ }, _ = new Zt(l), I = new en(l);
2452
2452
  switch (a) {
2453
2453
  case V.Ping:
2454
- this.session.setPingReceived(), this.session.execute(k).then((() => {
2454
+ this.session.setPingReceived(), this.session.execute(I).then((() => {
2455
2455
  z.receivedAuthenticationRequired = 0;
2456
2456
  })).catch(((T) => P(this, void 0, void 0, (function* () {
2457
2457
  T.code === this.session.authenticationRequiredErrorCode && z.receivedAuthenticationRequired >= 0 && (z.receivedAuthenticationRequired += 1, z.receivedAuthenticationRequired > 1 && this.session.hasAutoReconnect() && (m.warn("Ping failed twice with Authentication Required. Re-logging in..."), this.session.login(), z.receivedAuthenticationRequired = -1));
@@ -2564,26 +2564,26 @@ class z {
2564
2564
  A === "INVALID_PACKET" && b();
2565
2565
  }));
2566
2566
  }
2567
- } }, k = yield n.vertoSubscribe(_).catch(((g) => {
2567
+ } }, I = yield n.vertoSubscribe(_).catch(((g) => {
2568
2568
  m.error("liveArray subscription error:", g);
2569
2569
  }));
2570
- st(k, a) && b();
2570
+ st(I, a) && b();
2571
2571
  break;
2572
2572
  }
2573
2573
  case "conference-liveArray-part": {
2574
2574
  let b = null;
2575
2575
  if (a && n._existsSubscription(i, a)) {
2576
- const { callId: k = null } = n.subscriptions[i][a];
2577
- if (b = n.calls[k] || null, k !== null) {
2576
+ const { callId: I = null } = n.subscriptions[i][a];
2577
+ if (b = n.calls[I] || null, I !== null) {
2578
2578
  const g = { type: oe.conferenceUpdate, action: se.Leave, conferenceName: o, participantId: Number(p), role: f };
2579
- j(x.Notification, g, k, !1) || j(x.Notification, g, n.uuid), b === null && ue(x.Notification, null, k);
2579
+ j(x.Notification, g, I, !1) || j(x.Notification, g, n.uuid), b === null && ue(x.Notification, null, I);
2580
2580
  }
2581
2581
  }
2582
2582
  const _ = [a, l, u, d];
2583
- n.vertoUnsubscribe({ nodeId: this.nodeId, channels: _ }).then((({ unsubscribedChannels: k = [] }) => {
2584
- b && (b.channels = b.channels.filter(((g) => !k.includes(g))));
2585
- })).catch(((k) => {
2586
- m.error("liveArray unsubscribe error:", k);
2583
+ n.vertoUnsubscribe({ nodeId: this.nodeId, channels: _ }).then((({ unsubscribedChannels: I = [] }) => {
2584
+ b && (b.channels = b.channels.filter(((g) => !I.includes(g))));
2585
+ })).catch(((I) => {
2586
+ m.error("liveArray unsubscribe error:", I);
2587
2587
  }));
2588
2588
  break;
2589
2589
  }
@@ -2622,7 +2622,7 @@ class fi extends pi {
2622
2622
  }));
2623
2623
  }
2624
2624
  validateOptions() {
2625
- return Ue(this.options) || ke(this.options);
2625
+ return Ue(this.options) || Ie(this.options);
2626
2626
  }
2627
2627
  newCall(e) {
2628
2628
  if (!this.validateCallOptions(e)) throw new Error("Verto.newCall() error: destinationNumber is required.");
@@ -2640,11 +2640,11 @@ class fi extends pi {
2640
2640
  return this.vertoUnsubscribe(e);
2641
2641
  }
2642
2642
  validateCallOptions(e) {
2643
- return !!ke(this.options) || !!e.destinationNumber;
2643
+ return !!Ie(this.options) || !!e.destinationNumber;
2644
2644
  }
2645
2645
  _onSocketOpen() {
2646
2646
  return P(this, void 0, void 0, (function* () {
2647
- return Ue(this.options) ? this.handleLoginOnSocketOpen() : ke(this.options) ? this.handleAnonymousLoginOnSocketOpen() : void 0;
2647
+ return Ue(this.options) ? this.handleLoginOnSocketOpen() : Ie(this.options) ? this.handleAnonymousLoginOnSocketOpen() : void 0;
2648
2648
  }));
2649
2649
  }
2650
2650
  _onSocketMessage(e) {
@@ -2707,9 +2707,9 @@ function vi() {
2707
2707
  var p = n ? n + d : d, f = this._events[p];
2708
2708
  return f ? f.fn ? 1 : f.length : 0;
2709
2709
  }, l.prototype.emit = function(d, p, f, w, b, _) {
2710
- var k = n ? n + d : d;
2711
- if (!this._events[k]) return !1;
2712
- var g = this._events[k], C = arguments.length, T, A;
2710
+ var I = n ? n + d : d;
2711
+ if (!this._events[I]) return !1;
2712
+ var g = this._events[I], C = arguments.length, T, A;
2713
2713
  if (g.fn) {
2714
2714
  switch (g.once && this.removeListener(d, g.fn, void 0, !0), C) {
2715
2715
  case 1:
@@ -2764,8 +2764,8 @@ function vi() {
2764
2764
  if (_.fn)
2765
2765
  _.fn === p && (!w || _.once) && (!f || _.context === f) && o(this, b);
2766
2766
  else {
2767
- for (var k = 0, g = [], C = _.length; k < C; k++)
2768
- (_[k].fn !== p || w && !_[k].once || f && _[k].context !== f) && g.push(_[k]);
2767
+ for (var I = 0, g = [], C = _.length; I < C; I++)
2768
+ (_[I].fn !== p || w && !_[I].once || f && _[I].context !== f) && g.push(_[I]);
2769
2769
  g.length ? this._events[b] = g.length === 1 ? g[0] : g : o(this, b);
2770
2770
  }
2771
2771
  return this;
@@ -2791,43 +2791,43 @@ function bi() {
2791
2791
  "warn",
2792
2792
  "error"
2793
2793
  ], a = {}, o = null;
2794
- function l(k, g) {
2795
- var C = k[g];
2794
+ function l(I, g) {
2795
+ var C = I[g];
2796
2796
  if (typeof C.bind == "function")
2797
- return C.bind(k);
2797
+ return C.bind(I);
2798
2798
  try {
2799
- return Function.prototype.bind.call(C, k);
2799
+ return Function.prototype.bind.call(C, I);
2800
2800
  } catch {
2801
2801
  return function() {
2802
- return Function.prototype.apply.apply(C, [k, arguments]);
2802
+ return Function.prototype.apply.apply(C, [I, arguments]);
2803
2803
  };
2804
2804
  }
2805
2805
  }
2806
2806
  function u() {
2807
2807
  console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace();
2808
2808
  }
2809
- function d(k) {
2810
- return k === "debug" && (k = "log"), typeof console === n ? !1 : k === "trace" && i ? u : console[k] !== void 0 ? l(console, k) : console.log !== void 0 ? l(console, "log") : e;
2809
+ function d(I) {
2810
+ return I === "debug" && (I = "log"), typeof console === n ? !1 : I === "trace" && i ? u : console[I] !== void 0 ? l(console, I) : console.log !== void 0 ? l(console, "log") : e;
2811
2811
  }
2812
2812
  function p() {
2813
- for (var k = this.getLevel(), g = 0; g < s.length; g++) {
2813
+ for (var I = this.getLevel(), g = 0; g < s.length; g++) {
2814
2814
  var C = s[g];
2815
- this[C] = g < k ? e : this.methodFactory(C, k, this.name);
2815
+ this[C] = g < I ? e : this.methodFactory(C, I, this.name);
2816
2816
  }
2817
- if (this.log = this.debug, typeof console === n && k < this.levels.SILENT)
2817
+ if (this.log = this.debug, typeof console === n && I < this.levels.SILENT)
2818
2818
  return "No console available for logging";
2819
2819
  }
2820
- function f(k) {
2820
+ function f(I) {
2821
2821
  return function() {
2822
- typeof console !== n && (p.call(this), this[k].apply(this, arguments));
2822
+ typeof console !== n && (p.call(this), this[I].apply(this, arguments));
2823
2823
  };
2824
2824
  }
2825
- function w(k, g, C) {
2826
- return d(k) || f.apply(this, arguments);
2825
+ function w(I, g, C) {
2826
+ return d(I) || f.apply(this, arguments);
2827
2827
  }
2828
- function b(k, g) {
2828
+ function b(I, g) {
2829
2829
  var C = this, T, A, O, D = "loglevel";
2830
- typeof k == "string" ? D += ":" + k : typeof k == "symbol" && (D = void 0);
2830
+ typeof I == "string" ? D += ":" + I : typeof I == "symbol" && (D = void 0);
2831
2831
  function q(h) {
2832
2832
  var v = (s[h] || "silent").toUpperCase();
2833
2833
  if (!(typeof window === n || !D)) {
@@ -2878,7 +2878,7 @@ function bi() {
2878
2878
  return v;
2879
2879
  throw new TypeError("log.setLevel() called with invalid level: " + h);
2880
2880
  }
2881
- C.name = k, C.levels = {
2881
+ C.name = I, C.levels = {
2882
2882
  TRACE: 0,
2883
2883
  DEBUG: 1,
2884
2884
  INFO: 2,
@@ -2934,14 +2934,14 @@ J.methodFactory = (t, e, n) => {
2934
2934
  };
2935
2935
  };
2936
2936
  J.setLevel("info");
2937
- function ki(t, e) {
2937
+ function Ii(t, e) {
2938
2938
  let n = 0;
2939
2939
  return (...i) => {
2940
2940
  const s = Date.now();
2941
2941
  s - n >= e && (n = s, t(...i));
2942
2942
  };
2943
2943
  }
2944
- const Ii = 10, Ei = 500, Ti = 100, Nt = 20;
2944
+ const ki = 10, Ei = 500, Ti = 100, Nt = 20;
2945
2945
  class Ai {
2946
2946
  remoteIntervalId = null;
2947
2947
  localIntervalId = null;
@@ -2969,9 +2969,9 @@ class Ai {
2969
2969
  minSpeechDurationMs;
2970
2970
  maxLatencyMs;
2971
2971
  constructor(e) {
2972
- this.volumeThreshold = e?.volumeThreshold ?? Ii, this.silenceDurationMs = e?.silenceDurationMs ?? Ei, this.minSpeechDurationMs = e?.minSpeechDurationMs ?? Ti, this.maxLatencyMs = e?.maxLatencyMs;
2972
+ this.volumeThreshold = e?.volumeThreshold ?? ki, this.silenceDurationMs = e?.silenceDurationMs ?? Ei, this.minSpeechDurationMs = e?.minSpeechDurationMs ?? Ti, this.maxLatencyMs = e?.maxLatencyMs;
2973
2973
  }
2974
- updateAgentState = ki((e) => {
2974
+ updateAgentState = Ii((e) => {
2975
2975
  J.debug("AudioStreamMonitor updateAgentState", e), J.debug("Previous state:", this.lastState), e.state !== this.lastState && (this.lastState = e.state, Ve.emit("conversation.agent.state", e));
2976
2976
  }, 100);
2977
2977
  /**
@@ -3156,17 +3156,22 @@ class Ut extends vt {
3156
3156
  transcription;
3157
3157
  agentId;
3158
3158
  versionId;
3159
+ conversationId;
3159
3160
  debug;
3160
3161
  audioStreamMonitor;
3161
3162
  activeCall;
3162
3163
  constructor(e) {
3163
- super(), this.agentId = e.agentId, this.versionId = e.versionId || "main", this.debug = e.debug || !1, this.activeCall = null, J.setLevel(this.debug ? "debug" : "info"), this.telnyxRTC = new gi({
3164
+ super(), this.agentId = e.agentId, this.versionId = e.versionId || "main", this.conversationId = e.conversationId, this.debug = e.debug || !1, this.activeCall = null, J.setLevel(this.debug ? "debug" : "info");
3165
+ const n = {
3166
+ target_id: e.agentId,
3167
+ target_type: "ai_assistant",
3168
+ target_version_id: e.versionId
3169
+ };
3170
+ e.conversationId && (n.target_params = {
3171
+ conversation_id: e.conversationId
3172
+ }), this.telnyxRTC = new gi({
3164
3173
  env: e.environment || "production",
3165
- anonymous_login: {
3166
- target_id: e.agentId,
3167
- target_type: "ai_assistant",
3168
- target_version_id: e.versionId
3169
- },
3174
+ anonymous_login: n,
3170
3175
  debug: e.debug || !1,
3171
3176
  trickleIce: e.trickleIce
3172
3177
  }), this.telnyxRTC.on(x.Ready, this.onClientReady), this.telnyxRTC.on(x.Error, this.onClientOrSocketError), this.telnyxRTC.on(x.SocketError, this.onClientOrSocketError), this.telnyxRTC.on(x.Notification, this.onNotification), this.transcription = new Di(this.telnyxRTC), this.transcription.addListener("transcript.item", this.onTranscriptItem), Ve.addListener(
@@ -3351,7 +3356,7 @@ function Ui() {
3351
3356
  switch (typeof y.tag == "number" && console.error(
3352
3357
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
3353
3358
  ), y.$$typeof) {
3354
- case k:
3359
+ case I:
3355
3360
  return "Portal";
3356
3361
  case O:
3357
3362
  return y.displayName || "Context";
@@ -3521,7 +3526,7 @@ React keys must be passed directly to JSX without using spread:
3521
3526
  function w(y) {
3522
3527
  return typeof y == "object" && y !== null && y.$$typeof === _;
3523
3528
  }
3524
- var b = ht, _ = Symbol.for("react.transitional.element"), k = Symbol.for("react.portal"), g = Symbol.for("react.fragment"), C = Symbol.for("react.strict_mode"), T = Symbol.for("react.profiler"), A = Symbol.for("react.consumer"), O = Symbol.for("react.context"), D = Symbol.for("react.forward_ref"), q = Symbol.for("react.suspense"), F = Symbol.for("react.suspense_list"), L = Symbol.for("react.memo"), r = Symbol.for("react.lazy"), c = Symbol.for("react.activity"), h = Symbol.for("react.client.reference"), v = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, S = Object.prototype.hasOwnProperty, E = Array.isArray, I = console.createTask ? console.createTask : function() {
3529
+ var b = ht, _ = Symbol.for("react.transitional.element"), I = Symbol.for("react.portal"), g = Symbol.for("react.fragment"), C = Symbol.for("react.strict_mode"), T = Symbol.for("react.profiler"), A = Symbol.for("react.consumer"), O = Symbol.for("react.context"), D = Symbol.for("react.forward_ref"), q = Symbol.for("react.suspense"), F = Symbol.for("react.suspense_list"), L = Symbol.for("react.memo"), r = Symbol.for("react.lazy"), c = Symbol.for("react.activity"), h = Symbol.for("react.client.reference"), v = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, S = Object.prototype.hasOwnProperty, E = Array.isArray, k = console.createTask ? console.createTask : function() {
3525
3530
  return null;
3526
3531
  };
3527
3532
  b = {
@@ -3532,7 +3537,7 @@ React keys must be passed directly to JSX without using spread:
3532
3537
  var R, $ = {}, ee = b.react_stack_bottom_frame.bind(
3533
3538
  b,
3534
3539
  a
3535
- )(), ne = I(i(a)), G = {};
3540
+ )(), ne = k(i(a)), G = {};
3536
3541
  Se.Fragment = g, Se.jsx = function(y, M, U) {
3537
3542
  var B = 1e4 > v.recentlyCreatedOwnerStacks++;
3538
3543
  return p(
@@ -3541,7 +3546,7 @@ React keys must be passed directly to JSX without using spread:
3541
3546
  U,
3542
3547
  !1,
3543
3548
  B ? Error("react-stack-top-frame") : ee,
3544
- B ? I(i(y)) : ne
3549
+ B ? k(i(y)) : ne
3545
3550
  );
3546
3551
  }, Se.jsxs = function(y, M, U) {
3547
3552
  var B = 1e4 > v.recentlyCreatedOwnerStacks++;
@@ -3551,7 +3556,7 @@ React keys must be passed directly to JSX without using spread:
3551
3556
  U,
3552
3557
  !0,
3553
3558
  B ? Error("react-stack-top-frame") : ee,
3554
- B ? I(i(y)) : ne
3559
+ B ? k(i(y)) : ne
3555
3560
  );
3556
3561
  };
3557
3562
  })()), Se;
@@ -3674,17 +3679,17 @@ const Fi = (t, e, ...n) => e.read(...n), Vi = (t, e, ...n) => e.write(...n), Bi
3674
3679
  }
3675
3680
  for (let w = u.length - 1; w >= 0; --w) {
3676
3681
  const [b, _] = u[w];
3677
- let k = !1;
3682
+ let I = !1;
3678
3683
  for (const g of _.d.keys())
3679
3684
  if (g !== b && s.has(g)) {
3680
- k = !0;
3685
+ I = !0;
3681
3686
  break;
3682
3687
  }
3683
- k && (o(t, b), l(t, b)), i.delete(b);
3688
+ I && (o(t, b), l(t, b)), i.delete(b);
3684
3689
  }
3685
3690
  }, lt = /* @__PURE__ */ new WeakSet(), zi = (t, e) => {
3686
3691
  var n, i;
3687
- const s = X(t), a = s[1], o = s[2], l = s[3], u = s[6], d = s[7], p = s[11], f = s[12], w = s[13], b = s[14], _ = s[16], k = s[17], g = p(t, e);
3692
+ const s = X(t), a = s[1], o = s[2], l = s[3], u = s[6], d = s[7], p = s[11], f = s[12], w = s[13], b = s[14], _ = s[16], I = s[17], g = p(t, e);
3688
3693
  if (Vt(g)) {
3689
3694
  if (a.has(e) && o.get(e) !== g.n)
3690
3695
  return g;
@@ -3700,7 +3705,7 @@ const Fi = (t, e, ...n) => e.read(...n), Vi = (t, e, ...n) => e.write(...n), Bi
3700
3705
  g.d.clear();
3701
3706
  let C = !0;
3702
3707
  function T() {
3703
- a.has(e) && (k(t, e), w(t), f(t));
3708
+ a.has(e) && (I(t, e), w(t), f(t));
3704
3709
  }
3705
3710
  function A(L) {
3706
3711
  var r;
@@ -3759,7 +3764,7 @@ const Fi = (t, e, ...n) => e.read(...n), Vi = (t, e, ...n) => e.write(...n), Bi
3759
3764
  }, pn = (t, e, ...n) => {
3760
3765
  const i = X(t), s = i[3], a = i[6], o = i[8], l = i[11], u = i[12], d = i[13], p = i[14], f = i[15], w = i[17];
3761
3766
  let b = !0;
3762
- const _ = (g) => Be(p(t, g)), k = (g, ...C) => {
3767
+ const _ = (g) => Be(p(t, g)), I = (g, ...C) => {
3763
3768
  var T;
3764
3769
  const A = l(t, g);
3765
3770
  try {
@@ -3777,7 +3782,7 @@ const Fi = (t, e, ...n) => e.read(...n), Vi = (t, e, ...n) => e.write(...n), Bi
3777
3782
  }
3778
3783
  };
3779
3784
  try {
3780
- return o(t, e, _, k, ...n);
3785
+ return o(t, e, _, I, ...n);
3781
3786
  } finally {
3782
3787
  b = !1;
3783
3788
  }
@@ -3787,8 +3792,8 @@ const Fi = (t, e, ...n) => e.read(...n), Vi = (t, e, ...n) => e.write(...n), Bi
3787
3792
  if (w && !dn(f.v)) {
3788
3793
  for (const [b, _] of f.d)
3789
3794
  if (!w.d.has(b)) {
3790
- const k = l(t, b);
3791
- d(t, b).t.add(e), w.d.add(b), _ !== k.n && (a.add(b), u(t, b), (n = o.c) == null || n.call(o, b));
3795
+ const I = l(t, b);
3796
+ d(t, b).t.add(e), w.d.add(b), _ !== I.n && (a.add(b), u(t, b), (n = o.c) == null || n.call(o, b));
3792
3797
  }
3793
3798
  for (const b of w.d)
3794
3799
  if (!f.d.has(b)) {
@@ -3803,14 +3808,14 @@ const Fi = (t, e, ...n) => e.read(...n), Vi = (t, e, ...n) => e.write(...n), Bi
3803
3808
  let _ = s.get(e);
3804
3809
  if (!_) {
3805
3810
  f(t, e);
3806
- for (const k of b.d.keys())
3807
- fn(t, k).t.add(e);
3811
+ for (const I of b.d.keys())
3812
+ fn(t, I).t.add(e);
3808
3813
  if (_ = {
3809
3814
  l: /* @__PURE__ */ new Set(),
3810
3815
  d: new Set(b.d.keys()),
3811
3816
  t: /* @__PURE__ */ new Set()
3812
3817
  }, s.set(e, _), at(e)) {
3813
- const k = () => {
3818
+ const I = () => {
3814
3819
  let g = !0;
3815
3820
  const C = (...T) => {
3816
3821
  try {
@@ -3833,7 +3838,7 @@ const Fi = (t, e, ...n) => e.read(...n), Vi = (t, e, ...n) => e.write(...n), Bi
3833
3838
  g = !1;
3834
3839
  }
3835
3840
  };
3836
- a.add(k);
3841
+ a.add(I);
3837
3842
  }
3838
3843
  (n = o.m) == null || n.call(o, e);
3839
3844
  }
@@ -4016,7 +4021,7 @@ const dt = (t) => typeof t?.then == "function", ut = (t) => {
4016
4021
  }), nt.set(t, n)), n;
4017
4022
  };
4018
4023
  function ze(t, e) {
4019
- const { delay: n, unstable_promiseStatus: i = !ht.use } = {}, s = mn(), [[a, o, l], u] = kn(
4024
+ const { delay: n, unstable_promiseStatus: i = !ht.use } = {}, s = mn(), [[a, o, l], u] = In(
4020
4025
  (p) => {
4021
4026
  const f = s.get(t);
4022
4027
  return Object.is(p[0], f) && p[1] === s && p[2] === t ? p : [f, s, t];
@@ -4042,7 +4047,7 @@ function ze(t, e) {
4042
4047
  u();
4043
4048
  });
4044
4049
  return u(), p;
4045
- }, [s, t, n, i]), In(d), dt(d)) {
4050
+ }, [s, t, n, i]), kn(d), dt(d)) {
4046
4051
  const p = Bt(d, () => s.get(t));
4047
4052
  return i && ut(p), cs(p);
4048
4053
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@telnyx/ai-agent-lib",
3
3
  "private": false,
4
- "version": "0.2.13",
4
+ "version": "0.3.0-beta.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",