@telnyx/ai-agent-lib 0.2.0 → 0.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.
- package/dist/audio-stream-monitor.d.ts +1 -1
- package/dist/index.js +274 -274
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import ht, { useReducer as
|
|
2
|
-
function
|
|
1
|
+
import ht, { useReducer as Tn, useEffect as pe, useDebugValue as An, useCallback as Rn, useContext as Gt, createContext as Wt, useState as xn } from "react";
|
|
2
|
+
function Ht(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]);
|
|
5
5
|
if (t != null && typeof Object.getOwnPropertySymbols == "function") {
|
|
@@ -33,34 +33,34 @@ function L(t, e, n, i) {
|
|
|
33
33
|
l((i = i.apply(t, [])).next());
|
|
34
34
|
}));
|
|
35
35
|
}
|
|
36
|
-
var vt = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto < "u" && typeof msCrypto.getRandomValues == "function" && msCrypto.getRandomValues.bind(msCrypto),
|
|
37
|
-
function
|
|
36
|
+
var vt = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto < "u" && typeof msCrypto.getRandomValues == "function" && msCrypto.getRandomValues.bind(msCrypto), On = new Uint8Array(16);
|
|
37
|
+
function Ln() {
|
|
38
38
|
if (!vt) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
39
|
-
return vt(
|
|
39
|
+
return vt(On);
|
|
40
40
|
}
|
|
41
|
-
for (var
|
|
41
|
+
for (var qt = [], xe = 0; xe < 256; ++xe) qt[xe] = (xe + 256).toString(16).substr(1);
|
|
42
42
|
function me(t, e, n) {
|
|
43
43
|
var i = e && n || 0;
|
|
44
44
|
typeof t == "string" && (e = t === "binary" ? new Array(16) : null, t = null);
|
|
45
|
-
var s = (t = t || {}).random || (t.rng ||
|
|
45
|
+
var s = (t = t || {}).random || (t.rng || Ln)();
|
|
46
46
|
if (s[6] = 15 & s[6] | 64, s[8] = 63 & s[8] | 128, e) for (var r = 0; r < 16; ++r) e[i + r] = s[r];
|
|
47
47
|
return e || (function(o, d) {
|
|
48
|
-
var l = 0, h =
|
|
48
|
+
var l = 0, h = qt;
|
|
49
49
|
return [h[o[l++]], h[o[l++]], h[o[l++]], h[o[l++]], "-", h[o[l++]], h[o[l++]], "-", h[o[l++]], h[o[l++]], "-", h[o[l++]], h[o[l++]], "-", h[o[l++]], h[o[l++]], h[o[l++]], h[o[l++]], h[o[l++]], h[o[l++]]].join("");
|
|
50
50
|
})(s);
|
|
51
51
|
}
|
|
52
|
-
const mt = "wss://rtc.telnyx.com",
|
|
52
|
+
const mt = "wss://rtc.telnyx.com", Jt = { urls: "stun:stun.l.google.com:19302" }, Mn = [{ urls: "stun:stun.telnyx.com:3478" }, Jt, { urls: "turn:turn.telnyx.com:3478?transport=tcp", username: "testuser", credential: "testpassword" }], Pn = [{ urls: "stun:stundev.telnyx.com:3478" }, Jt, { urls: "turn:turndev.telnyx.com:3478?transport=tcp", username: "testuser", credential: "testpassword" }];
|
|
53
53
|
var O;
|
|
54
54
|
(function(t) {
|
|
55
55
|
t.SocketOpen = "telnyx.socket.open", t.SocketClose = "telnyx.socket.close", t.SocketError = "telnyx.socket.error", t.SocketMessage = "telnyx.socket.message", t.SpeedTest = "telnyx.internal.speedtest", t.Ready = "telnyx.ready", t.Error = "telnyx.error", t.Notification = "telnyx.notification", t.StatsFrame = "telnyx.stats.frame", t.StatsReport = "telnyx.stats.report", t.Messages = "telnyx.messages", t.Calls = "telnyx.calls", t.MediaError = "telnyx.rtc.mediaError", t.PeerConnectionFailureError = "telnyx.rtc.peerConnectionFailureError";
|
|
56
56
|
})(O || (O = {}));
|
|
57
|
-
var
|
|
58
|
-
function
|
|
57
|
+
var Dn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
58
|
+
function Yt(t, e) {
|
|
59
59
|
return t(e = { exports: {} }, e.exports), e.exports;
|
|
60
60
|
}
|
|
61
|
-
var
|
|
61
|
+
var Nn = Yt((function(t) {
|
|
62
62
|
var e, n;
|
|
63
|
-
e =
|
|
63
|
+
e = Dn, n = function() {
|
|
64
64
|
var i = function() {
|
|
65
65
|
}, s = "undefined", r = typeof window !== s && typeof window.navigator !== s && /Trident\/|MSIE /.test(window.navigator.userAgent), o = ["trace", "debug", "info", "warn", "error"];
|
|
66
66
|
function d(p, S) {
|
|
@@ -167,9 +167,9 @@ var Dn = Jt((function(t) {
|
|
|
167
167
|
}, w.default = w, w;
|
|
168
168
|
}, t.exports ? t.exports = n() : e.log = n();
|
|
169
169
|
}));
|
|
170
|
-
const y =
|
|
170
|
+
const y = Nn.getLogger("telnyx"), jn = y.methodFactory;
|
|
171
171
|
y.methodFactory = (t, e, n) => {
|
|
172
|
-
const i =
|
|
172
|
+
const i = jn(t, e, n);
|
|
173
173
|
return function() {
|
|
174
174
|
const s = [(/* @__PURE__ */ new Date()).toISOString().replace("T", " ").replace("Z", ""), "-"];
|
|
175
175
|
for (let r = 0; r < arguments.length; r++) s.push(arguments[r]);
|
|
@@ -185,21 +185,21 @@ const Oe = (t) => {
|
|
|
185
185
|
y.warn("Verto LA invalid media JSON string:", r);
|
|
186
186
|
}
|
|
187
187
|
return { participantId: Number(e), participantNumber: n, participantName: i, codec: s, media: d, participantData: o };
|
|
188
|
-
},
|
|
188
|
+
}, zt = (t) => {
|
|
189
189
|
if (typeof t != "string") return t;
|
|
190
190
|
try {
|
|
191
191
|
return JSON.parse(t);
|
|
192
192
|
} catch {
|
|
193
193
|
return t;
|
|
194
194
|
}
|
|
195
|
-
}, ye = (t) => t instanceof Function || typeof t == "function", De = (t) => typeof document == "object" && "getElementById" in document ? typeof t == "string" ? document.getElementById(t) || null : typeof t == "function" ? t() : t instanceof HTMLMediaElement ? t : null : null,
|
|
195
|
+
}, ye = (t) => t instanceof Function || typeof t == "function", De = (t) => typeof document == "object" && "getElementById" in document ? typeof t == "string" ? document.getElementById(t) || null : typeof t == "function" ? t() : t instanceof HTMLMediaElement ? t : null : null, Un = /^(ws|wss):\/\//, Kt = (t, e = null) => {
|
|
196
196
|
const { result: n = {}, error: i } = t;
|
|
197
197
|
if (i) return { error: i };
|
|
198
198
|
const { result: s = null } = n;
|
|
199
199
|
if (s === null) return e !== null && (n.node_id = e), { result: n };
|
|
200
200
|
const { code: r = null, node_id: o = null, result: d = null } = s;
|
|
201
|
-
return r && r !== "200" ? { error: s } : d ?
|
|
202
|
-
},
|
|
201
|
+
return r && r !== "200" ? { error: s } : d ? Kt(d, o) : { result: s };
|
|
202
|
+
}, Qt = (t, e) => Math.floor(Math.random() * (e - t + 1) + t), Ne = ({ 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, r, o;
|
|
204
204
|
let d = "", l = "";
|
|
205
205
|
return !((n = (e = t?.result) === null || e === void 0 ? void 0 : e.params) === null || n === void 0) && n.state && (d = (s = (i = t?.result) === null || i === void 0 ? void 0 : i.params) === null || s === void 0 ? void 0 : s.state), !((r = t?.params) === null || r === void 0) && r.state && (l = (o = t?.params) === null || o === void 0 ? void 0 : o.state), d || l;
|
|
@@ -207,10 +207,10 @@ const Oe = (t) => {
|
|
|
207
207
|
function yt({ debounceTime: t }) {
|
|
208
208
|
let e, n;
|
|
209
209
|
return { promise: new Promise(((i, s) => {
|
|
210
|
-
e = t ?
|
|
210
|
+
e = t ? $n(i, t) : i, n = s;
|
|
211
211
|
})), resolve: e, reject: n };
|
|
212
212
|
}
|
|
213
|
-
const
|
|
213
|
+
const $n = (t, e) => {
|
|
214
214
|
let n;
|
|
215
215
|
return (...i) => {
|
|
216
216
|
clearTimeout(n), n = window.setTimeout((() => {
|
|
@@ -221,7 +221,7 @@ const Un = (t, e) => {
|
|
|
221
221
|
function fe() {
|
|
222
222
|
return sessionStorage.getItem(ft);
|
|
223
223
|
}
|
|
224
|
-
var K, de,
|
|
224
|
+
var K, de, F;
|
|
225
225
|
typeof window < "u" && window.addEventListener("beforeunload", (() => {
|
|
226
226
|
sessionStorage.removeItem(ft);
|
|
227
227
|
})), (function(t) {
|
|
@@ -230,8 +230,8 @@ typeof window < "u" && window.addEventListener("beforeunload", (() => {
|
|
|
230
230
|
t.Inbound = "inbound", t.Outbound = "outbound";
|
|
231
231
|
})(de || (de = {})), (function(t) {
|
|
232
232
|
t.Invite = "telnyx_rtc.invite", t.Attach = "telnyx_rtc.attach", t.Answer = "telnyx_rtc.answer", t.Info = "telnyx_rtc.info", t.Candidate = "telnyx_rtc.candidate", t.EndOfCandidates = "telnyx_rtc.endOfCandidates", t.Display = "telnyx_rtc.display", t.Media = "telnyx_rtc.media", t.Event = "telnyx_rtc.event", t.Bye = "telnyx_rtc.bye", t.Punt = "telnyx_rtc.punt", t.Broadcast = "telnyx_rtc.broadcast", t.Subscribe = "telnyx_rtc.subscribe", t.Unsubscribe = "telnyx_rtc.unsubscribe", t.ClientReady = "telnyx_rtc.clientReady", t.Modify = "telnyx_rtc.modify", t.Ringing = "telnyx_rtc.ringing", t.GatewayState = "telnyx_rtc.gatewayState", t.Ping = "telnyx_rtc.ping", t.Pong = "telnyx_rtc.pong";
|
|
233
|
-
})(
|
|
234
|
-
const oe = { generic: "event", [
|
|
233
|
+
})(F || (F = {}));
|
|
234
|
+
const oe = { generic: "event", [F.Display]: "participantData", [F.Attach]: "participantData", conferenceUpdate: "conferenceUpdate", callUpdate: "callUpdate", vertoClientReady: "vertoClientReady", userMediaError: "userMediaError", peerConnectionFailureError: "peerConnectionFailureError" }, Fn = { destinationNumber: "", remoteCallerName: "Outbound Call", remoteCallerNumber: "", callerName: "", callerNumber: "", audio: !0, useStereo: !1, debug: !1, debugOutput: "socket", attach: !1, screenShare: !1, userVariables: {}, mediaSettings: { useSdpASBandwidthKbps: !1, sdpASBandwidthKbps: 0 }, mutedMicOnStart: !1 };
|
|
235
235
|
var N, tt, se, ae, te;
|
|
236
236
|
(function(t) {
|
|
237
237
|
t[t.New = 0] = "New", t[t.Requesting = 1] = "Requesting", t[t.Trying = 2] = "Trying", t[t.Recovering = 3] = "Recovering", t[t.Ringing = 4] = "Ringing", t[t.Answering = 5] = "Answering", t[t.Early = 6] = "Early", t[t.Active = 7] = "Active", t[t.Held = 8] = "Held", t[t.Hangup = 9] = "Hangup", t[t.Destroy = 10] = "Destroy", t[t.Purge = 11] = "Purge";
|
|
@@ -244,16 +244,16 @@ var N, tt, se, ae, te;
|
|
|
244
244
|
})(ae || (ae = {})), (function(t) {
|
|
245
245
|
t.REGED = "REGED", t.UNREGED = "UNREGED", t.NOREG = "NOREG", t.FAILED = "FAILED", t.FAIL_WAIT = "FAIL_WAIT", t.REGISTER = "REGISTER", t.TRYING = "TRYING", t.EXPIRED = "EXPIRED", t.UNREGISTER = "UNREGISTER";
|
|
246
246
|
})(te || (te = {}));
|
|
247
|
-
const be = "GLOBAL", ie = {}, Ae = (t, e) => `${t}|${e}`,
|
|
247
|
+
const be = "GLOBAL", ie = {}, Ae = (t, e) => `${t}|${e}`, Xt = (t, e = be) => Ae(t, e) in ie, le = (t, e, n = be) => {
|
|
248
248
|
const i = Ae(t, n);
|
|
249
249
|
i in ie || (ie[i] = []), ie[i].push(e);
|
|
250
|
-
},
|
|
250
|
+
}, Zt = (t, e, n = be) => {
|
|
251
251
|
const i = function(s) {
|
|
252
252
|
ue(t, i, n), e(s);
|
|
253
253
|
};
|
|
254
254
|
return i.prototype.targetRef = e, le(t, i, n);
|
|
255
255
|
}, ue = (t, e, n = be) => {
|
|
256
|
-
if (!
|
|
256
|
+
if (!Xt(t, n)) return !1;
|
|
257
257
|
const i = Ae(t, n);
|
|
258
258
|
if (ye(e))
|
|
259
259
|
for (let s = ie[i].length - 1; s >= 0; s--) {
|
|
@@ -262,36 +262,36 @@ const be = "GLOBAL", ie = {}, Ae = (t, e) => `${t}|${e}`, Qt = (t, e = be) => Ae
|
|
|
262
262
|
}
|
|
263
263
|
else ie[i] = [];
|
|
264
264
|
return ie[i].length === 0 && delete ie[i], !0;
|
|
265
|
-
},
|
|
265
|
+
}, $ = (t, e, n = be, i = !0) => {
|
|
266
266
|
const s = i && n !== be;
|
|
267
|
-
if (!
|
|
267
|
+
if (!Xt(t, n)) return s && $(t, e), !1;
|
|
268
268
|
const r = Ae(t, n), o = ie[r].length;
|
|
269
|
-
if (!o) return s &&
|
|
269
|
+
if (!o) return s && $(t, e), !1;
|
|
270
270
|
for (let d = o - 1; d >= 0; d--) ie[r][d](e);
|
|
271
|
-
return s &&
|
|
271
|
+
return s && $(t, e), !0;
|
|
272
272
|
}, Ke = (t) => {
|
|
273
273
|
const e = Ae(t, "");
|
|
274
274
|
Object.keys(ie).filter(((n) => n.indexOf(e) === 0)).forEach(((n) => delete ie[n]));
|
|
275
275
|
};
|
|
276
|
-
let
|
|
277
|
-
const
|
|
276
|
+
let Bn = typeof WebSocket < "u" ? WebSocket : null;
|
|
277
|
+
const Vn = 0, Gn = 1, Wn = 2, Hn = 3;
|
|
278
278
|
class bt {
|
|
279
279
|
constructor(e) {
|
|
280
280
|
this.session = e, this.previousGatewayState = "", this._wsClient = null, this._host = mt, this._timers = {}, this._useCanaryRtcServer = !1, this._hasCanaryBeenUsed = !1, this.upDur = null, this.downDur = null;
|
|
281
281
|
const { host: n, env: i, region: s, trickleIce: r, useCanaryRtcServer: o } = e.options;
|
|
282
|
-
i && (this._host = i === "development" ? "wss://rtcdev.telnyx.com" : mt), n && (this._host = ((d) => `${
|
|
282
|
+
i && (this._host = i === "development" ? "wss://rtcdev.telnyx.com" : mt), n && (this._host = ((d) => `${Un.test(d) ? "" : "wss://"}${d}`)(n)), s && (this._host = this._host.replace(/rtc(dev)?/, `${s}.rtc$1`)), (r || o) && (this._useCanaryRtcServer = !0);
|
|
283
283
|
}
|
|
284
284
|
get connected() {
|
|
285
|
-
return this._wsClient && this._wsClient.readyState ===
|
|
285
|
+
return this._wsClient && this._wsClient.readyState === Gn;
|
|
286
286
|
}
|
|
287
287
|
get connecting() {
|
|
288
|
-
return this._wsClient && this._wsClient.readyState ===
|
|
288
|
+
return this._wsClient && this._wsClient.readyState === Vn;
|
|
289
289
|
}
|
|
290
290
|
get closing() {
|
|
291
|
-
return this._wsClient && this._wsClient.readyState ===
|
|
291
|
+
return this._wsClient && this._wsClient.readyState === Wn;
|
|
292
292
|
}
|
|
293
293
|
get closed() {
|
|
294
|
-
return this._wsClient && this._wsClient.readyState ===
|
|
294
|
+
return this._wsClient && this._wsClient.readyState === Hn;
|
|
295
295
|
}
|
|
296
296
|
get isAlive() {
|
|
297
297
|
return this.connecting || this.connected;
|
|
@@ -302,16 +302,16 @@ class bt {
|
|
|
302
302
|
connect() {
|
|
303
303
|
const e = new URL(this._host);
|
|
304
304
|
let n = fe();
|
|
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"), y.debug("first canary connection. Refreshing voice_sdk_id")), this._hasCanaryBeenUsed = !0), this._wsClient = new
|
|
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"), y.debug("first canary connection. Refreshing voice_sdk_id")), this._hasCanaryBeenUsed = !0), this._wsClient = new Bn(e.toString()), this._wsClient.onopen = (i) => $(O.SocketOpen, i, this.session.uuid), this._wsClient.onclose = (i) => $(O.SocketClose, i, this.session.uuid), this._wsClient.onerror = (i) => $(O.SocketError, { error: i, sessionId: this.session.sessionid }, this.session.uuid), this._wsClient.onmessage = (i) => {
|
|
306
306
|
var s, r;
|
|
307
|
-
const o =
|
|
307
|
+
const o = zt(i.data);
|
|
308
308
|
var d;
|
|
309
309
|
if (typeof o != "string") {
|
|
310
310
|
if (o.voice_sdk_id && (d = o.voice_sdk_id, sessionStorage.setItem(ft, d)), this._unsetTimer(o.id), y.debug(`RECV:
|
|
311
311
|
`, JSON.stringify(o, null, 2), `
|
|
312
|
-
`), te[`${(r = (s = o?.result) === null || s === void 0 ? void 0 : s.params) === null || r === void 0 ? void 0 : r.state}`] ||
|
|
312
|
+
`), te[`${(r = (s = o?.result) === null || s === void 0 ? void 0 : s.params) === null || r === void 0 ? void 0 : r.state}`] || !$(o.id, o)) {
|
|
313
313
|
const l = pt(o);
|
|
314
|
-
|
|
314
|
+
$(O.SocketMessage, o, this.session.uuid), l && (this.previousGatewayState = l);
|
|
315
315
|
}
|
|
316
316
|
} else this._handleStringResponse(o);
|
|
317
317
|
};
|
|
@@ -322,8 +322,8 @@ class bt {
|
|
|
322
322
|
send(e) {
|
|
323
323
|
const { request: n } = e, i = new Promise(((s, r) => {
|
|
324
324
|
if (n.hasOwnProperty("result")) return s();
|
|
325
|
-
|
|
326
|
-
const { result: d, error: l } =
|
|
325
|
+
Zt(n.id, ((o) => {
|
|
326
|
+
const { result: d, error: l } = Kt(o);
|
|
327
327
|
return l ? r(l) : s(d);
|
|
328
328
|
}));
|
|
329
329
|
}));
|
|
@@ -343,7 +343,7 @@ class bt {
|
|
|
343
343
|
this.upDur = parseInt(e.substring(4));
|
|
344
344
|
break;
|
|
345
345
|
case "D":
|
|
346
|
-
this.downDur = parseInt(e.substring(4)),
|
|
346
|
+
this.downDur = parseInt(e.substring(4)), $(O.SpeedTest, { upDur: this.upDur, downDur: this.downDur }, this.session.uuid);
|
|
347
347
|
}
|
|
348
348
|
else y.warn("Unknown message from socket", e);
|
|
349
349
|
}
|
|
@@ -357,39 +357,39 @@ const _t = { id: "callID", destinationNumber: "destination_number", remoteCaller
|
|
|
357
357
|
class Z extends Re {
|
|
358
358
|
constructor(e = {}) {
|
|
359
359
|
if (super(), e.hasOwnProperty("dialogParams")) {
|
|
360
|
-
const n =
|
|
360
|
+
const n = Ht(e.dialogParams, ["remoteSdp", "localStream", "remoteStream", "onNotification", "camId", "micId", "speakerId"]);
|
|
361
361
|
for (const i in _t) i && n.hasOwnProperty(i) && (n[_t[i]] = n[i], delete n[i]);
|
|
362
362
|
e.dialogParams = n;
|
|
363
363
|
}
|
|
364
364
|
this.buildRequest({ method: this.toString(), params: e });
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
|
-
class
|
|
367
|
+
class en extends Z {
|
|
368
368
|
constructor(e) {
|
|
369
|
-
super(), this.method =
|
|
369
|
+
super(), this.method = F.GatewayState, this.buildRequest({ method: this.method, voice_sdk_id: e, params: {} });
|
|
370
370
|
}
|
|
371
371
|
}
|
|
372
|
-
class
|
|
372
|
+
class qn {
|
|
373
373
|
constructor(e) {
|
|
374
374
|
this.pendingRequestId = null, this.onSocketMessage = (n) => L(this, void 0, void 0, (function* () {
|
|
375
375
|
n.id === this.pendingRequestId && this.gatewayStateTask.resolve(pt(n));
|
|
376
376
|
})), this.getIsRegistered = () => L(this, void 0, void 0, (function* () {
|
|
377
|
-
const n = new
|
|
377
|
+
const n = new en(fe());
|
|
378
378
|
this.pendingRequestId = n.request.id, this.gatewayStateTask = yt({}), this.session.execute(n);
|
|
379
379
|
const i = yield this.gatewayStateTask.promise;
|
|
380
380
|
return !!i && [te.REGISTER, te.REGED].includes(i);
|
|
381
381
|
})), this.session = e, this.gatewayStateTask = yt({}), this.session.on("telnyx.socket.message", this.onSocketMessage);
|
|
382
382
|
}
|
|
383
383
|
}
|
|
384
|
-
class
|
|
384
|
+
class tn extends Z {
|
|
385
385
|
constructor(e) {
|
|
386
|
-
super(), this.method =
|
|
386
|
+
super(), this.method = F.Ping, this.buildRequest({ method: this.method, voice_sdk_id: e, params: {} });
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
|
-
class
|
|
389
|
+
class Jn {
|
|
390
390
|
constructor(e) {
|
|
391
391
|
if (this.options = e, this.uuid = me(), this.sessionid = "", this.subscriptions = {}, this.signature = null, this.relayProtocol = null, this.contexts = [], this.timeoutErrorCode = -32e3, this.invalidMethodErrorCode = -32601, this.authenticationRequiredErrorCode = -32e3, this.connection = null, this._jwtAuth = !1, this._autoReconnect = !0, this._idle = !1, this._executeQueue = [], !this.validateOptions()) throw new Error("Invalid init options");
|
|
392
|
-
e.debug && y.setLevel("debug"), this._onSocketOpen = this._onSocketOpen.bind(this), this.onNetworkClose = this.onNetworkClose.bind(this), this._onSocketMessage = this._onSocketMessage.bind(this), this._handleLoginError = this._handleLoginError.bind(this), this._attachListeners(), this.connection = new bt(this), this.registerAgent = new
|
|
392
|
+
e.debug && y.setLevel("debug"), this._onSocketOpen = this._onSocketOpen.bind(this), this.onNetworkClose = this.onNetworkClose.bind(this), this._onSocketMessage = this._onSocketMessage.bind(this), this._handleLoginError = this._handleLoginError.bind(this), this._attachListeners(), this.connection = new bt(this), this.registerAgent = new qn(this);
|
|
393
393
|
}
|
|
394
394
|
get __logger() {
|
|
395
395
|
return y;
|
|
@@ -403,7 +403,7 @@ class qn {
|
|
|
403
403
|
}));
|
|
404
404
|
}
|
|
405
405
|
get reconnectDelay() {
|
|
406
|
-
return 1e3 *
|
|
406
|
+
return 1e3 * Qt(2, 6);
|
|
407
407
|
}
|
|
408
408
|
execute(e) {
|
|
409
409
|
return this._idle ? new Promise(((n) => this._executeQueue.push({ resolve: n, msg: e }))) : this.connected ? this.connection.send(e) : new Promise(((n) => {
|
|
@@ -435,7 +435,7 @@ class qn {
|
|
|
435
435
|
}));
|
|
436
436
|
}
|
|
437
437
|
_handleLoginError(e) {
|
|
438
|
-
|
|
438
|
+
$(O.Error, { error: e, sessionId: this.sessionid }, this.uuid);
|
|
439
439
|
}
|
|
440
440
|
_onSocketOpen() {
|
|
441
441
|
return L(this, void 0, void 0, (function* () {
|
|
@@ -472,7 +472,7 @@ class qn {
|
|
|
472
472
|
this._idle = !0, clearTimeout(this._keepAliveTimeout), this.connection && this.connection.close();
|
|
473
473
|
}
|
|
474
474
|
_resetKeepAlive() {
|
|
475
|
-
this._pong === !1 && (y.warn("No ping/pong received, forcing PING ACK to keep alive"), this.execute(new
|
|
475
|
+
this._pong === !1 && (y.warn("No ping/pong received, forcing PING ACK to keep alive"), this.execute(new tn(fe()))), clearTimeout(this._keepAliveTimeout), this._triggerKeepAliveTimeoutCheck();
|
|
476
476
|
}
|
|
477
477
|
_triggerKeepAliveTimeoutCheck() {
|
|
478
478
|
this._pong = !1, this._keepAliveTimeout = setTimeout((() => this._resetKeepAlive()), 35e3);
|
|
@@ -499,7 +499,7 @@ class qn {
|
|
|
499
499
|
const nt = (t) => navigator.mediaDevices.getUserMedia(t), ge = (t) => t && t instanceof MediaStream, Ee = (t, e) => {
|
|
500
500
|
const n = De(t);
|
|
501
501
|
n !== null && (n.getAttribute("autoplay") || n.setAttribute("autoplay", "autoplay"), n.getAttribute("playsinline") || n.setAttribute("playsinline", "playsinline"), n.srcObject = e);
|
|
502
|
-
},
|
|
502
|
+
}, nn = (t, e) => L(void 0, void 0, void 0, (function* () {
|
|
503
503
|
const n = De(t);
|
|
504
504
|
if (n === null) return y.info("No HTMLMediaElement to attach the speakerId"), !1;
|
|
505
505
|
if (typeof e != "string") return y.info(`Invalid speaker deviceId: '${e}'`), !1;
|
|
@@ -508,10 +508,10 @@ const nt = (t) => navigator.mediaDevices.getUserMedia(t), ge = (t) => t && t ins
|
|
|
508
508
|
} catch {
|
|
509
509
|
return !1;
|
|
510
510
|
}
|
|
511
|
-
})),
|
|
511
|
+
})), Yn = (t) => {
|
|
512
512
|
t && t.readyState === "live" && t.stop();
|
|
513
513
|
}, Te = (t) => {
|
|
514
|
-
ge(t) && t.getTracks().forEach(
|
|
514
|
+
ge(t) && t.getTracks().forEach(Yn), t = null;
|
|
515
515
|
}, je = (t) => L(void 0, void 0, void 0, (function* () {
|
|
516
516
|
y.info("RTCService.getUserMedia", t);
|
|
517
517
|
const { audio: e, video: n } = t;
|
|
@@ -541,7 +541,7 @@ const nt = (t) => navigator.mediaDevices.getUserMedia(t), ge = (t) => t && t ins
|
|
|
541
541
|
if (t === r || e === o) return r;
|
|
542
542
|
}
|
|
543
543
|
return null;
|
|
544
|
-
})),
|
|
544
|
+
})), zn = (t) => {
|
|
545
545
|
const e = navigator.mediaDevices.getSupportedConstraints();
|
|
546
546
|
Object.keys(t).map(((n) => {
|
|
547
547
|
e.hasOwnProperty(n) && t[n] !== null && t[n] !== void 0 || delete t[n];
|
|
@@ -588,7 +588,7 @@ const nt = (t) => navigator.mediaDevices.getUserMedia(t), ge = (t) => t && t ins
|
|
|
588
588
|
ve(t, "audio", !1);
|
|
589
589
|
}, Ct = (t) => {
|
|
590
590
|
ve(t, "audio", null);
|
|
591
|
-
},
|
|
591
|
+
}, Kn = (t) => ((e, n = null) => {
|
|
592
592
|
if (!ge(e)) return null;
|
|
593
593
|
let i = [];
|
|
594
594
|
switch (n) {
|
|
@@ -603,7 +603,7 @@ const nt = (t) => navigator.mediaDevices.getUserMedia(t), ge = (t) => t && t ins
|
|
|
603
603
|
}
|
|
604
604
|
return i.some(((s) => s.enabled));
|
|
605
605
|
})(t, "audio");
|
|
606
|
-
function
|
|
606
|
+
function Qn() {
|
|
607
607
|
try {
|
|
608
608
|
const { browserInfo: t, name: e, version: n, supportAudio: i, supportVideo: s } = (function() {
|
|
609
609
|
if (!window || !window.navigator || !window.navigator.userAgent) throw new Error("You should use @telnyx/webrtc in a web browser such as Chrome|Firefox|Safari");
|
|
@@ -657,80 +657,80 @@ function Et(t) {
|
|
|
657
657
|
(function(t) {
|
|
658
658
|
t.not_supported = "not supported", t.full = "full", t.partial = "partial";
|
|
659
659
|
})(H || (H = {}));
|
|
660
|
-
var
|
|
661
|
-
class
|
|
660
|
+
var sn = "2.25.12", We = sn;
|
|
661
|
+
class on extends Z {
|
|
662
662
|
constructor(e, n, i, s, r = {}, o) {
|
|
663
663
|
super(), this.method = "login";
|
|
664
664
|
const d = { login: e, passwd: n, login_token: i, userVariables: r, reconnection: o, loginParams: {}, "User-Agent": { sdkVersion: We, data: navigator.userAgent } };
|
|
665
665
|
s && (d.sessid = s), this.buildRequest({ method: this.method, params: d });
|
|
666
666
|
}
|
|
667
667
|
}
|
|
668
|
-
class
|
|
668
|
+
class Xn extends Z {
|
|
669
669
|
constructor(e, n) {
|
|
670
670
|
super(), this.buildRequest({ id: e, result: { method: n } });
|
|
671
671
|
}
|
|
672
672
|
}
|
|
673
673
|
class Tt extends Z {
|
|
674
674
|
toString() {
|
|
675
|
-
return
|
|
675
|
+
return F.Invite;
|
|
676
676
|
}
|
|
677
677
|
}
|
|
678
678
|
class At extends Z {
|
|
679
679
|
toString() {
|
|
680
|
-
return
|
|
680
|
+
return F.Answer;
|
|
681
681
|
}
|
|
682
682
|
}
|
|
683
683
|
class rt extends Z {
|
|
684
684
|
toString() {
|
|
685
|
-
return
|
|
685
|
+
return F.Attach;
|
|
686
686
|
}
|
|
687
687
|
}
|
|
688
|
-
class
|
|
688
|
+
class Zn extends Z {
|
|
689
689
|
toString() {
|
|
690
|
-
return
|
|
690
|
+
return F.Bye;
|
|
691
691
|
}
|
|
692
692
|
}
|
|
693
|
-
class
|
|
693
|
+
class rn extends Z {
|
|
694
694
|
toString() {
|
|
695
|
-
return
|
|
695
|
+
return F.Candidate;
|
|
696
696
|
}
|
|
697
697
|
}
|
|
698
|
-
class
|
|
698
|
+
class ei extends Z {
|
|
699
699
|
toString() {
|
|
700
|
-
return
|
|
700
|
+
return F.EndOfCandidates;
|
|
701
701
|
}
|
|
702
702
|
}
|
|
703
703
|
class Qe extends Z {
|
|
704
704
|
toString() {
|
|
705
|
-
return
|
|
705
|
+
return F.Modify;
|
|
706
706
|
}
|
|
707
707
|
}
|
|
708
708
|
class Rt extends Z {
|
|
709
709
|
toString() {
|
|
710
|
-
return
|
|
710
|
+
return F.Info;
|
|
711
711
|
}
|
|
712
712
|
}
|
|
713
|
-
class
|
|
713
|
+
class ti extends Z {
|
|
714
714
|
toString() {
|
|
715
|
-
return
|
|
715
|
+
return F.Broadcast;
|
|
716
716
|
}
|
|
717
717
|
}
|
|
718
|
-
class
|
|
718
|
+
class ni extends Z {
|
|
719
719
|
toString() {
|
|
720
|
-
return
|
|
720
|
+
return F.Subscribe;
|
|
721
721
|
}
|
|
722
722
|
}
|
|
723
|
-
class
|
|
723
|
+
class ii extends Z {
|
|
724
724
|
toString() {
|
|
725
|
-
return
|
|
725
|
+
return F.Unsubscribe;
|
|
726
726
|
}
|
|
727
727
|
}
|
|
728
|
-
class
|
|
728
|
+
class si extends Re {
|
|
729
729
|
constructor(e, n) {
|
|
730
730
|
super(), this.method = "ai_conversation", this.buildRequest({ method: this.method, params: { type: "conversation.item.create", previous_item_id: null, item: { id: me(), type: "message", role: "user", content: [{ type: "input_text", text: e }, ...n?.map(((i) => ({ type: "image_url", image_url: { url: i } })))] } } });
|
|
731
731
|
}
|
|
732
732
|
}
|
|
733
|
-
var Le,
|
|
733
|
+
var Le, an = Yt((function(t, e) {
|
|
734
734
|
var n;
|
|
735
735
|
function i() {
|
|
736
736
|
}
|
|
@@ -1304,9 +1304,9 @@ var Le, rn = Jt((function(t, e) {
|
|
|
1304
1304
|
}
|
|
1305
1305
|
};
|
|
1306
1306
|
}));
|
|
1307
|
-
(Le =
|
|
1308
|
-
var
|
|
1309
|
-
function
|
|
1307
|
+
(Le = an) && Le.__esModule && Object.prototype.hasOwnProperty.call(Le, "default") && Le.default;
|
|
1308
|
+
var oi = an.WebRTCStats;
|
|
1309
|
+
function ri(t) {
|
|
1310
1310
|
const { packetsLost: e, packetsReceived: n, jitter: i, rtt: s } = t, r = (function(h) {
|
|
1311
1311
|
const { jitter: f, rtt: v } = h, _ = f + v / 2;
|
|
1312
1312
|
return 0.024 * _ + 0.11 * (_ - 177.3) * (_ > 177.3 ? 1 : 0);
|
|
@@ -1316,20 +1316,20 @@ function oi(t) {
|
|
|
1316
1316
|
})({ packetsLost: e, packetsReceived: n }), d = 93.2 - r - o + 0, l = 1 + 0.035 * d + 7e-6 * d * (d - 60) * (100 - d);
|
|
1317
1317
|
return Math.min(Math.max(l, 1), 5);
|
|
1318
1318
|
}
|
|
1319
|
-
function
|
|
1319
|
+
function ai(t) {
|
|
1320
1320
|
return isNaN(t) ? null : t > 4.2 ? "excellent" : t >= 4.1 && t <= 4.2 ? "good" : t >= 3.7 && t <= 4 ? "fair" : t >= 3.1 && t <= 3.6 ? "poor" : "bad";
|
|
1321
1321
|
}
|
|
1322
|
-
class
|
|
1322
|
+
class ci extends Re {
|
|
1323
1323
|
constructor(e, n) {
|
|
1324
1324
|
super(), this.buildRequest({ type: "debug_report_start", debug_report_id: e, debug_report_version: 1, call_id: n });
|
|
1325
1325
|
}
|
|
1326
1326
|
}
|
|
1327
|
-
class
|
|
1327
|
+
class di extends Re {
|
|
1328
1328
|
constructor(e, n) {
|
|
1329
1329
|
super(), this.buildRequest({ type: "debug_report_stop", debug_report_id: e, debug_report_version: 1, call_id: n });
|
|
1330
1330
|
}
|
|
1331
1331
|
}
|
|
1332
|
-
class
|
|
1332
|
+
class li extends Re {
|
|
1333
1333
|
constructor(e, n) {
|
|
1334
1334
|
super(), this.buildRequest({ type: "debug_report_data", debug_report_id: e, debug_report_version: 1, debug_report_data: n });
|
|
1335
1335
|
}
|
|
@@ -1338,22 +1338,22 @@ function xt(t, e) {
|
|
|
1338
1338
|
var n, i;
|
|
1339
1339
|
return { errorCode: t.errorCode, errorText: t.errorText, url: t.url, address: t.address, port: t.port, connectionState: e.connectionState, iceConnectionState: e.iceConnectionState, iceGatheringState: e.iceGatheringState, signalingState: e.signalingState, localDescriptionType: (n = e.localDescription) === null || n === void 0 ? void 0 : n.type, remoteDescriptionType: (i = e.remoteDescription) === null || i === void 0 ? void 0 : i.type };
|
|
1340
1340
|
}
|
|
1341
|
-
function
|
|
1342
|
-
const n = me(), i = new
|
|
1343
|
-
r.event === "stats" &&
|
|
1341
|
+
function ui(t, e) {
|
|
1342
|
+
const n = me(), i = new oi({ getStatsInterval: 1e3, rawStats: !1, statsObject: !0, filteredStats: !1, remote: !0, debug: !1, logLevel: "warn" }), s = (r) => L(this, void 0, void 0, (function* () {
|
|
1343
|
+
r.event === "stats" && $(O.StatsFrame, (function({ data: o }) {
|
|
1344
1344
|
var d, l, h, f, v, _, w, C;
|
|
1345
|
-
const { audio: k, remote: p } = o, { audio: S } = p, A = (l = (d = S.inbound[0]) === null || d === void 0 ? void 0 : d.jitter) !== null && l !== void 0 ? l : 1 / 0, E = (f = (h = S.inbound[0]) === null || h === void 0 ? void 0 : h.roundTripTime) !== null && f !== void 0 ? f : 1 / 0, P = (_ = (v = k.inbound[0]) === null || v === void 0 ? void 0 : v.packetsReceived) !== null && _ !== void 0 ? _ : -1, D = (C = (w = k.inbound[0]) === null || w === void 0 ? void 0 : w.packetsLost) !== null && C !== void 0 ? C : -1, q =
|
|
1346
|
-
return { jitter: A, rtt: E, mos: q, quality:
|
|
1347
|
-
})(r), t.uuid), yield t.execute(new
|
|
1345
|
+
const { audio: k, remote: p } = o, { audio: S } = p, A = (l = (d = S.inbound[0]) === null || d === void 0 ? void 0 : d.jitter) !== null && l !== void 0 ? l : 1 / 0, E = (f = (h = S.inbound[0]) === null || h === void 0 ? void 0 : h.roundTripTime) !== null && f !== void 0 ? f : 1 / 0, P = (_ = (v = k.inbound[0]) === null || v === void 0 ? void 0 : v.packetsReceived) !== null && _ !== void 0 ? _ : -1, D = (C = (w = k.inbound[0]) === null || w === void 0 ? void 0 : w.packetsLost) !== null && C !== void 0 ? C : -1, q = ri({ jitter: 1e3 * A, rtt: 1e3 * E, packetsLost: D, packetsReceived: P });
|
|
1346
|
+
return { jitter: A, rtt: E, mos: q, quality: ai(q), inboundAudio: k.inbound[0], outboundAudio: k.outbound[0], remoteInboundAudio: S.inbound[0], remoteOutboundAudio: S.outbound[0] };
|
|
1347
|
+
})(r), t.uuid), yield t.execute(new li(n, r));
|
|
1348
1348
|
}));
|
|
1349
1349
|
return { start: (r, o, d) => L(this, void 0, void 0, (function* () {
|
|
1350
|
-
yield t.execute(new
|
|
1350
|
+
yield t.execute(new ci(n, e)), i.on("timeline", s), yield new Promise(((l) => setTimeout(l, 500))), i.addConnection({ pc: r, peerId: o, connectionId: d });
|
|
1351
1351
|
})), stop: (r) => L(this, void 0, void 0, (function* () {
|
|
1352
1352
|
const o = i.getTimeline();
|
|
1353
|
-
|
|
1353
|
+
$(O.StatsReport, o, t.uuid), r === "file" && (function(d, l) {
|
|
1354
1354
|
const h = new Blob([JSON.stringify(d)], { type: "application/json" }), f = URL.createObjectURL(h), v = document.createElement("a");
|
|
1355
1355
|
v.href = f, v.download = `${l}.json`, v.click(), URL.revokeObjectURL(f);
|
|
1356
|
-
})(o, `webrtc-stats-${n}-${Date.now()}`), yield t.execute(new
|
|
1356
|
+
})(o, `webrtc-stats-${n}-${Date.now()}`), yield t.execute(new di(n, e)), i.removeAllPeers(), i.destroy();
|
|
1357
1357
|
})), reportConnectionStateChange: (r) => {
|
|
1358
1358
|
const o = { event: "connectionstatechange-detailed", tag: "connection", timestamp: (/* @__PURE__ */ new Date()).toISOString(), data: r };
|
|
1359
1359
|
s(o);
|
|
@@ -1362,25 +1362,25 @@ function li(t, e) {
|
|
|
1362
1362
|
s(o);
|
|
1363
1363
|
} };
|
|
1364
1364
|
}
|
|
1365
|
-
const
|
|
1365
|
+
const cn = (t, e) => {
|
|
1366
1366
|
const { contentType: n, canvasType: i, callID: s, canvasInfo: r = null, currentLayerIdx: o = -1 } = e;
|
|
1367
1367
|
r && i !== "mcu-personal-canvas" && delete r.memberID;
|
|
1368
|
-
const d = { type: oe.conferenceUpdate, call: t.calls[s], canvasInfo:
|
|
1368
|
+
const d = { type: oe.conferenceUpdate, call: t.calls[s], canvasInfo: hi(r), currentLayerIdx: o };
|
|
1369
1369
|
switch (n) {
|
|
1370
1370
|
case "layer-info": {
|
|
1371
1371
|
const l = Object.assign({ action: se.LayerInfo }, d);
|
|
1372
|
-
|
|
1372
|
+
$(O.Notification, l, t.uuid);
|
|
1373
1373
|
break;
|
|
1374
1374
|
}
|
|
1375
1375
|
case "layout-info": {
|
|
1376
1376
|
const l = Object.assign({ action: se.LayoutInfo }, d);
|
|
1377
|
-
|
|
1377
|
+
$(O.Notification, l, t.uuid);
|
|
1378
1378
|
break;
|
|
1379
1379
|
}
|
|
1380
1380
|
}
|
|
1381
|
-
},
|
|
1381
|
+
}, hi = (t) => {
|
|
1382
1382
|
const e = JSON.stringify(t).replace(/memberID/g, "participantId").replace(/ID"/g, 'Id"').replace(/POS"/g, 'Pos"');
|
|
1383
|
-
return
|
|
1383
|
+
return zt(e);
|
|
1384
1384
|
};
|
|
1385
1385
|
class Ot {
|
|
1386
1386
|
constructor(e, n, i, s, r) {
|
|
@@ -1412,7 +1412,7 @@ class Ot {
|
|
|
1412
1412
|
})(this.instance, this._prevConnectionState);
|
|
1413
1413
|
this.statsReporter.reportConnectionStateChange(h);
|
|
1414
1414
|
}
|
|
1415
|
-
this._restartedIceOnConnectionStateFailed ? (y.debug("Peer Connection failed again after ICE restart. Recovering call via peer reconnection through error handling."),
|
|
1415
|
+
this._restartedIceOnConnectionStateFailed ? (y.debug("Peer Connection failed again after ICE restart. Recovering call via peer reconnection through error handling."), $(O.PeerConnectionFailureError, { error: new Error(`Peer Connection failed twice. previous state: ${this._prevConnectionState}, current state: ${d}`), sessionId: this._session.sessionid }, this.options.id)) : (this.instance.restartIce(), d === "failed" && (this._restartedIceOnConnectionStateFailed = !0, y.debug("ICE has been restarted on connection state failed.")), this._isTrickleIce() ? yield this.startTrickleIceNegotiation() : this.startNegotiation()), window.removeEventListener("online", l);
|
|
1416
1416
|
}));
|
|
1417
1417
|
navigator.onLine ? l() : window.addEventListener("online", l);
|
|
1418
1418
|
}
|
|
@@ -1483,13 +1483,13 @@ class Ot {
|
|
|
1483
1483
|
var e;
|
|
1484
1484
|
this.instance = (e = this._config(), new window.RTCPeerConnection(e)), this.instance.onsignalingstatechange = this.handleSignalingStateChangeEvent, this.instance.onnegotiationneeded = this.handleNegotiationNeededEvent, this.instance.ontrack = this.handleTrackEvent, this.instance.addEventListener("connectionstatechange", this.handleConnectionStateChange), this.instance.addEventListener("iceconnectionstatechange", this._handleIceConnectionStateChange), this.instance.addEventListener("icegatheringstatechange", this._handleIceGatheringStateChange), this.instance.addEventListener("addstream", ((n) => {
|
|
1485
1485
|
this.options.remoteStream = n.stream;
|
|
1486
|
-
})), this._registerPeerEvents(this.instance), this._prevConnectionState = this.instance.connectionState, this.isAnswer && (yield this._setRemoteDescription({ sdp: this.options.remoteSdp, type: K.Offer })), this.options.localStream = yield this._retrieveLocalStream().catch(((n) => (
|
|
1486
|
+
})), this._registerPeerEvents(this.instance), this._prevConnectionState = this.instance.connectionState, this.isAnswer && (yield this._setRemoteDescription({ sdp: this.options.remoteSdp, type: K.Offer })), this.options.localStream = yield this._retrieveLocalStream().catch(((n) => ($(O.MediaError, n, this.options.id), null))), this.options.mutedMicOnStart && ge(this.options.localStream) && (y.info("Muting local audio tracks on start"), ot(this.options.localStream)), performance.mark("peer-creation-end");
|
|
1487
1487
|
}));
|
|
1488
1488
|
}
|
|
1489
1489
|
init() {
|
|
1490
1490
|
var e;
|
|
1491
1491
|
return L(this, void 0, void 0, (function* () {
|
|
1492
|
-
yield this.createPeerConnection(), this.isDebugEnabled && (this.statsReporter =
|
|
1492
|
+
yield this.createPeerConnection(), this.isDebugEnabled && (this.statsReporter = ui(this._session, this.options.id), yield (e = this.statsReporter) === null || e === void 0 ? void 0 : e.start(this.instance, this._session.sessionid, this._session.sessionid));
|
|
1493
1493
|
const { localElement: n, localStream: i = null, screenShare: s = !1 } = this.options;
|
|
1494
1494
|
if (ge(i)) {
|
|
1495
1495
|
const r = i.getAudioTracks();
|
|
@@ -1633,7 +1633,7 @@ class Ot {
|
|
|
1633
1633
|
}
|
|
1634
1634
|
}
|
|
1635
1635
|
const Lt = We;
|
|
1636
|
-
class
|
|
1636
|
+
class dn {
|
|
1637
1637
|
constructor(e, n) {
|
|
1638
1638
|
this.session = e, this.id = "", this.state = N[N.New], this.prevState = "", this.channels = [], this.role = tt.Participant, this.extension = null, this._state = N.New, this._prevState = N.New, this.gotAnswer = !1, this.gotEarly = !1, this._lastSerno = 0, this._targetNodeId = null, this._iceTimeout = null, this._iceDone = !1, this._statsBindings = [], this._statsIntervalId = null, this._pendingIceCandidates = [], this._isRemoteDescriptionSet = !1, this._checkConferenceSerno = (p) => {
|
|
1639
1639
|
const S = p < 0 || !this._lastSerno || this._lastSerno && p === this._lastSerno + 1;
|
|
@@ -1681,7 +1681,7 @@ class cn {
|
|
|
1681
1681
|
return `conference-member.${this.id}`;
|
|
1682
1682
|
}
|
|
1683
1683
|
get isAudioMuted() {
|
|
1684
|
-
return !
|
|
1684
|
+
return !Kn(this.options.localStream);
|
|
1685
1685
|
}
|
|
1686
1686
|
invite() {
|
|
1687
1687
|
return L(this, void 0, void 0, (function* () {
|
|
@@ -1715,9 +1715,9 @@ class cn {
|
|
|
1715
1715
|
return (h = this.peer) === null || h === void 0 || h.close(), this.setState(N.Destroy);
|
|
1716
1716
|
};
|
|
1717
1717
|
if (this.stopRingtone(), this.stopRingback(), d) {
|
|
1718
|
-
const h = new
|
|
1718
|
+
const h = new Zn({ sipCode: this.sipCode, sip_call_id: this.sipCallId, sessid: this.session.sessionid, dialogParams: this.options, cause: "USER_BUSY", causeCode: 17 });
|
|
1719
1719
|
this._execute(h).catch(((f) => {
|
|
1720
|
-
y.error("telnyx_rtc.bye failed!", f),
|
|
1720
|
+
y.error("telnyx_rtc.bye failed!", f), $(O.Error, { error: f, sessionId: this.session.sessionid }, this.session.uuid);
|
|
1721
1721
|
})).then(l.bind(this));
|
|
1722
1722
|
} else l();
|
|
1723
1723
|
}
|
|
@@ -1826,7 +1826,7 @@ class cn {
|
|
|
1826
1826
|
case N.Active:
|
|
1827
1827
|
setTimeout((() => {
|
|
1828
1828
|
const { remoteElement: n, speakerId: i } = this.options;
|
|
1829
|
-
n && i &&
|
|
1829
|
+
n && i && nn(n, i);
|
|
1830
1830
|
}), 0);
|
|
1831
1831
|
break;
|
|
1832
1832
|
case N.Destroy:
|
|
@@ -1836,35 +1836,35 @@ class cn {
|
|
|
1836
1836
|
handleMessage(e) {
|
|
1837
1837
|
const { method: n, params: i } = e;
|
|
1838
1838
|
switch (n) {
|
|
1839
|
-
case
|
|
1839
|
+
case F.Answer:
|
|
1840
1840
|
if (this.gotAnswer = !0, this._state >= N.Active) return;
|
|
1841
1841
|
this._state >= N.Early && this.setState(N.Active), this.gotEarly || this._onRemoteSdp(i.sdp), this.stopRingback(), this.stopRingtone();
|
|
1842
1842
|
break;
|
|
1843
|
-
case
|
|
1843
|
+
case F.Media:
|
|
1844
1844
|
if (this._state >= N.Early) return;
|
|
1845
1845
|
this.gotEarly = !0, this._onRemoteSdp(i.sdp);
|
|
1846
1846
|
break;
|
|
1847
|
-
case
|
|
1848
|
-
case
|
|
1847
|
+
case F.Display:
|
|
1848
|
+
case F.Attach: {
|
|
1849
1849
|
const { display_name: r, display_number: o, display_direction: d } = i;
|
|
1850
1850
|
this.extension = o;
|
|
1851
1851
|
const l = d === de.Inbound ? de.Outbound : de.Inbound, h = { type: oe[n], call: this, displayName: r, displayNumber: o, displayDirection: l };
|
|
1852
|
-
|
|
1852
|
+
$(O.Notification, h, this.id) || $(O.Notification, h, this.session.uuid);
|
|
1853
1853
|
break;
|
|
1854
1854
|
}
|
|
1855
|
-
case
|
|
1855
|
+
case F.Candidate:
|
|
1856
1856
|
this._addIceCandidate(i);
|
|
1857
1857
|
break;
|
|
1858
|
-
case
|
|
1859
|
-
case
|
|
1858
|
+
case F.Info:
|
|
1859
|
+
case F.Event: {
|
|
1860
1860
|
const r = Object.assign(Object.assign({}, i), { type: oe.generic, call: this });
|
|
1861
|
-
|
|
1861
|
+
$(O.Notification, r, this.id) || $(O.Notification, r, this.session.uuid);
|
|
1862
1862
|
break;
|
|
1863
1863
|
}
|
|
1864
|
-
case
|
|
1864
|
+
case F.Ringing:
|
|
1865
1865
|
this.playRingback(), i.telnyx_call_control_id && (this.options.telnyxCallControlId = i.telnyx_call_control_id), i.telnyx_session_id && (this.options.telnyxSessionId = i.telnyx_session_id), i.telnyx_leg_id && (this.options.telnyxLegId = i.telnyx_leg_id);
|
|
1866
1866
|
break;
|
|
1867
|
-
case
|
|
1867
|
+
case F.Bye:
|
|
1868
1868
|
const s = i.client_state || i.clientState;
|
|
1869
1869
|
s && (this.options.clientState = s), this.stopRingback(), this.stopRingtone(), this.hangup(i, !1);
|
|
1870
1870
|
}
|
|
@@ -1922,7 +1922,7 @@ class cn {
|
|
|
1922
1922
|
return L(this, void 0, void 0, (function* () {
|
|
1923
1923
|
const n = { nodeId: this.nodeId, channels: [e], handler: (s) => {
|
|
1924
1924
|
const { eventData: r } = s;
|
|
1925
|
-
r.contentType === "layout-info" ? (r.callID = this.id,
|
|
1925
|
+
r.contentType === "layout-info" ? (r.callID = this.id, cn(this.session, r)) : y.error("Conference-Info unknown contentType", s);
|
|
1926
1926
|
} }, i = yield this.session.vertoSubscribe(n).catch(((s) => {
|
|
1927
1927
|
y.error("ConfInfo subscription error:", s);
|
|
1928
1928
|
}));
|
|
@@ -1950,7 +1950,7 @@ class cn {
|
|
|
1950
1950
|
}));
|
|
1951
1951
|
}
|
|
1952
1952
|
_requestAnotherLocalDescription() {
|
|
1953
|
-
ye(this.peer.onSdpReadyTwice) ?
|
|
1953
|
+
ye(this.peer.onSdpReadyTwice) ? $(O.Error, { error: new Error("SDP without candidates for the second time!"), sessionId: this.session.sessionid }, this.session.uuid) : (Object.defineProperty(this.peer, "onSdpReadyTwice", { value: this._onIceSdp.bind(this) }), this._iceDone = !1, this.peer.startNegotiation());
|
|
1954
1954
|
}
|
|
1955
1955
|
_onIceSdp(e) {
|
|
1956
1956
|
var n, i;
|
|
@@ -2012,7 +2012,7 @@ class cn {
|
|
|
2012
2012
|
e.candidate && e.candidate.candidate ? (y.debug("RTCPeer Candidate:", e.candidate), this._sendIceCandidate(e.candidate)) : this._sendEndOfCandidates();
|
|
2013
2013
|
}
|
|
2014
2014
|
_sendIceCandidate(e) {
|
|
2015
|
-
const n = new
|
|
2015
|
+
const n = new rn({ sessid: this.session.sessionid, candidate: e.candidate, sdpMLineIndex: e.sdpMLineIndex, sdpMid: e.sdpMid, dialogParams: this.options });
|
|
2016
2016
|
this._execute(n);
|
|
2017
2017
|
}
|
|
2018
2018
|
_addIceCandidate(e) {
|
|
@@ -2028,7 +2028,7 @@ class cn {
|
|
|
2028
2028
|
}));
|
|
2029
2029
|
}
|
|
2030
2030
|
_sendEndOfCandidates() {
|
|
2031
|
-
const e = new
|
|
2031
|
+
const e = new ei({ sessid: this.session.sessionid, endOfCandidates: !0, dialogParams: this.options });
|
|
2032
2032
|
this._execute(e), performance.mark("ice-gathering-end");
|
|
2033
2033
|
}
|
|
2034
2034
|
_resetTrickleIceCandidateState() {
|
|
@@ -2087,7 +2087,7 @@ class cn {
|
|
|
2087
2087
|
this._dispatchNotification(Object.assign({ type: oe.conferenceUpdate, call: this }, e));
|
|
2088
2088
|
}
|
|
2089
2089
|
_dispatchNotification(e) {
|
|
2090
|
-
this.options.screenShare !== !0 && (
|
|
2090
|
+
this.options.screenShare !== !0 && ($(O.Notification, e, this.id, !1) || $(O.Notification, e, this.session.uuid));
|
|
2091
2091
|
}
|
|
2092
2092
|
_execute(e) {
|
|
2093
2093
|
return this.nodeId && (e.targetNodeId = this.nodeId), this.session.execute(e);
|
|
@@ -2110,7 +2110,7 @@ class cn {
|
|
|
2110
2110
|
this._statsIntervalId && (clearInterval(this._statsIntervalId), this._statsIntervalId = null), y.info("Stats stopped");
|
|
2111
2111
|
}
|
|
2112
2112
|
}
|
|
2113
|
-
|
|
2113
|
+
dn.setStateTelnyx = (t) => {
|
|
2114
2114
|
if (t) {
|
|
2115
2115
|
switch (t._state) {
|
|
2116
2116
|
case N.Requesting:
|
|
@@ -2138,9 +2138,9 @@ cn.setStateTelnyx = (t) => {
|
|
|
2138
2138
|
return t;
|
|
2139
2139
|
}
|
|
2140
2140
|
};
|
|
2141
|
-
class he extends
|
|
2141
|
+
class he extends dn {
|
|
2142
2142
|
constructor() {
|
|
2143
|
-
super(...arguments), this._statsInterval = null, this.sendConversationMessage = (e, n) => this.session.execute(new
|
|
2143
|
+
super(...arguments), this._statsInterval = null, this.sendConversationMessage = (e, n) => this.session.execute(new si(e, n));
|
|
2144
2144
|
}
|
|
2145
2145
|
hangup(e = {}, n = !0) {
|
|
2146
2146
|
this.screenShare instanceof he && this.screenShare.hangup(e, n), super.hangup(e, n);
|
|
@@ -2165,7 +2165,7 @@ class he extends cn {
|
|
|
2165
2165
|
return L(this, void 0, void 0, (function* () {
|
|
2166
2166
|
this.options.speakerId = e;
|
|
2167
2167
|
const { remoteElement: n, speakerId: i } = this.options;
|
|
2168
|
-
return !(!n || !i) &&
|
|
2168
|
+
return !(!n || !i) && nn(n, i);
|
|
2169
2169
|
}));
|
|
2170
2170
|
}
|
|
2171
2171
|
_finalize() {
|
|
@@ -2188,7 +2188,7 @@ ${o.type}
|
|
|
2188
2188
|
}))), 2e3);
|
|
2189
2189
|
}
|
|
2190
2190
|
}
|
|
2191
|
-
class
|
|
2191
|
+
class pi extends Jn {
|
|
2192
2192
|
constructor(e) {
|
|
2193
2193
|
super(e), this.calls = {}, this.autoRecoverCalls = !0, this._iceServers = [], this._localElement = null, this._remoteElement = null, this._jwtAuth = !0, this._audioConstraints = !0, this._videoConstraints = !1, this._speaker = null, this._onlineHandler = null, this._offlineHandler = null, this._wasOffline = !1, this._videoConstraints = e.video || !1, this.iceServers = e.iceServers, this.ringtoneFile = e.ringtoneFile, this.ringbackFile = e.ringbackFile, this._setupNetworkListeners();
|
|
2194
2194
|
}
|
|
@@ -2234,7 +2234,7 @@ class hi extends qn {
|
|
|
2234
2234
|
}
|
|
2235
2235
|
speedTest(e) {
|
|
2236
2236
|
return new Promise(((n, i) => {
|
|
2237
|
-
if (
|
|
2237
|
+
if (Zt(O.SpeedTest, ((o) => {
|
|
2238
2238
|
const { upDur: d, downDur: l } = o, h = l ? 8 * e / (l / 1e3) / 1024 : 0;
|
|
2239
2239
|
n({ upDur: d, downDur: l, upKps: (d ? 8 * e / (d / 1e3) / 1024 : 0).toFixed(0), downKps: h.toFixed(0) });
|
|
2240
2240
|
}), this.uuid), !(e = Number(e))) return i(`Invalid parameter 'bytes': ${e}`);
|
|
@@ -2247,16 +2247,16 @@ class hi extends qn {
|
|
|
2247
2247
|
}));
|
|
2248
2248
|
}
|
|
2249
2249
|
getDevices() {
|
|
2250
|
-
return ke().catch(((e) => (
|
|
2250
|
+
return ke().catch(((e) => ($(O.MediaError, e, this.uuid), [])));
|
|
2251
2251
|
}
|
|
2252
2252
|
getVideoDevices() {
|
|
2253
|
-
return ke(ae.Video).catch(((e) => (
|
|
2253
|
+
return ke(ae.Video).catch(((e) => ($(O.MediaError, e, this.uuid), [])));
|
|
2254
2254
|
}
|
|
2255
2255
|
getAudioInDevices() {
|
|
2256
|
-
return ke(ae.AudioIn).catch(((e) => (
|
|
2256
|
+
return ke(ae.AudioIn).catch(((e) => ($(O.MediaError, e, this.uuid), [])));
|
|
2257
2257
|
}
|
|
2258
2258
|
getAudioOutDevices() {
|
|
2259
|
-
return ke(ae.AudioOut).catch(((e) => (y.error("getAudioOutDevices", e),
|
|
2259
|
+
return ke(ae.AudioOut).catch(((e) => (y.error("getAudioOutDevices", e), $(O.MediaError, e, this.uuid), [])));
|
|
2260
2260
|
}
|
|
2261
2261
|
validateDeviceId(e, n, i) {
|
|
2262
2262
|
return Ue(e, n, i);
|
|
@@ -2283,8 +2283,8 @@ class hi extends qn {
|
|
|
2283
2283
|
setAudioSettings(e) {
|
|
2284
2284
|
return L(this, void 0, void 0, (function* () {
|
|
2285
2285
|
if (!e) throw new Error("You need to provide the settings object");
|
|
2286
|
-
const { micId: n, micLabel: i } = e, s =
|
|
2287
|
-
return
|
|
2286
|
+
const { micId: n, micLabel: i } = e, s = Ht(e, ["micId", "micLabel"]);
|
|
2287
|
+
return zn(s), this._audioConstraints = yield ((r, o, d, l) => L(void 0, void 0, void 0, (function* () {
|
|
2288
2288
|
const { deviceId: h } = l;
|
|
2289
2289
|
if (h === void 0 && (r || o)) {
|
|
2290
2290
|
const f = yield Ue(r, o, d).catch(((v) => null));
|
|
@@ -2304,7 +2304,7 @@ class hi extends qn {
|
|
|
2304
2304
|
if (e && Array.isArray(e)) this._iceServers = e;
|
|
2305
2305
|
else {
|
|
2306
2306
|
const n = this.options.env === "development";
|
|
2307
|
-
this._iceServers = n ?
|
|
2307
|
+
this._iceServers = n ? Pn : Mn;
|
|
2308
2308
|
}
|
|
2309
2309
|
}
|
|
2310
2310
|
get iceServers() {
|
|
@@ -2330,13 +2330,13 @@ class hi extends qn {
|
|
|
2330
2330
|
}
|
|
2331
2331
|
vertoBroadcast({ nodeId: e, channel: n = "", data: i }) {
|
|
2332
2332
|
if (!n) throw new Error(`Invalid channel for broadcast: ${n}`);
|
|
2333
|
-
const s = new
|
|
2333
|
+
const s = new ti({ sessid: this.sessionid, eventChannel: n, data: i });
|
|
2334
2334
|
e && (s.targetNodeId = e), this.execute(s).catch(((r) => r));
|
|
2335
2335
|
}
|
|
2336
2336
|
vertoSubscribe({ nodeId: e, channels: n = [], handler: i }) {
|
|
2337
2337
|
return L(this, void 0, void 0, (function* () {
|
|
2338
2338
|
if (!(n = n.filter(((l) => l && !this._existsSubscription(this.relayProtocol, l)))).length) return {};
|
|
2339
|
-
const s = new
|
|
2339
|
+
const s = new ni({ sessid: this.sessionid, eventChannel: n });
|
|
2340
2340
|
e && (s.targetNodeId = e);
|
|
2341
2341
|
const r = yield this.execute(s), { unauthorized: o = [], subscribed: d = [] } = st(r);
|
|
2342
2342
|
return o.length && o.forEach(((l) => this._removeSubscription(this.relayProtocol, l))), d.forEach(((l) => this._addSubscription(this.relayProtocol, i, l))), r;
|
|
@@ -2345,7 +2345,7 @@ class hi extends qn {
|
|
|
2345
2345
|
vertoUnsubscribe({ nodeId: e, channels: n = [] }) {
|
|
2346
2346
|
return L(this, void 0, void 0, (function* () {
|
|
2347
2347
|
if (!(n = n.filter(((d) => d && this._existsSubscription(this.relayProtocol, d)))).length) return {};
|
|
2348
|
-
const i = new
|
|
2348
|
+
const i = new ii({ sessid: this.sessionid, eventChannel: n });
|
|
2349
2349
|
e && (i.targetNodeId = e);
|
|
2350
2350
|
const s = yield this.execute(i), { unsubscribed: r = [], notSubscribed: o = [] } = st(s);
|
|
2351
2351
|
return r.forEach(((d) => this._removeSubscription(this.relayProtocol, d))), o.forEach(((d) => this._removeSubscription(this.relayProtocol, d))), s;
|
|
@@ -2370,34 +2370,34 @@ class Mt {
|
|
|
2370
2370
|
this.code = n, this.message = e;
|
|
2371
2371
|
}
|
|
2372
2372
|
}
|
|
2373
|
-
class
|
|
2373
|
+
class ln extends Z {
|
|
2374
2374
|
constructor(e) {
|
|
2375
2375
|
super(), this.method = "anonymous_login";
|
|
2376
2376
|
const { target_type: n, target_id: i, target_version_id: s, userVariables: r, sessionId: o, reconnection: d } = e, l = { target_type: n, target_id: i, userVariables: r, reconnection: d, "User-Agent": { sdkVersion: We, data: navigator.userAgent } };
|
|
2377
2377
|
o && (l.sessid = o), s && (l.target_version_id = s), this.buildRequest({ method: this.method, params: l });
|
|
2378
2378
|
}
|
|
2379
2379
|
}
|
|
2380
|
-
const
|
|
2380
|
+
const fi = We;
|
|
2381
2381
|
class J {
|
|
2382
2382
|
constructor(e) {
|
|
2383
2383
|
this.session = e, this.handleLogin = () => L(this, void 0, void 0, (function* () {
|
|
2384
|
-
const { login: n, password: i, passwd: s, login_token: r, userVariables: o } = this.session.options, d = new
|
|
2384
|
+
const { login: n, password: i, passwd: s, login_token: r, userVariables: o } = this.session.options, d = new on(n, i || s, r, this.session.sessionid, o, !!fe()), l = yield this.session.execute(d).catch(this.session.handleLoginError);
|
|
2385
2385
|
l && (this.session.sessionid = l.sessid);
|
|
2386
2386
|
})), this.handleAnonymousLogin = () => L(this, void 0, void 0, (function* () {
|
|
2387
|
-
const { anonymous_login: n } = this.session.options, i = new
|
|
2387
|
+
const { anonymous_login: n } = this.session.options, i = new ln({ target_id: n.target_id, target_type: n.target_type, target_version_id: n.target_version_id, sessionId: this.session.sessionid, userVariables: this.session.options.userVariables, reconnection: !!fe() }), s = yield this.session.execute(i).catch(this.session.handleLoginError);
|
|
2388
2388
|
s && (this.session.sessionid = s.sessid);
|
|
2389
2389
|
}));
|
|
2390
2390
|
}
|
|
2391
2391
|
_ack(e, n) {
|
|
2392
|
-
const i = new
|
|
2392
|
+
const i = new Xn(e, n);
|
|
2393
2393
|
this.nodeId && (i.targetNodeId = this.nodeId), this.session.execute(i);
|
|
2394
2394
|
}
|
|
2395
2395
|
reconnectDelay() {
|
|
2396
|
-
return 1e3 *
|
|
2396
|
+
return 1e3 * Qt(2, 6);
|
|
2397
2397
|
}
|
|
2398
2398
|
handleMessage(e) {
|
|
2399
2399
|
var n;
|
|
2400
|
-
const { session: i } = this, { id: s, method: r, params: o = {}, voice_sdk_id: d } = e, l = o?.callID, h = o?.eventChannel, f = o?.eventType, v = r ===
|
|
2400
|
+
const { session: i } = this, { id: s, method: r, params: o = {}, voice_sdk_id: d } = e, l = o?.callID, h = o?.eventChannel, f = o?.eventType, v = r === F.Attach, _ = r === F.Punt;
|
|
2401
2401
|
let w = !1;
|
|
2402
2402
|
if (f === "channelPvtData") return this._handlePvtEvent(o.pvtData);
|
|
2403
2403
|
if (l && i.calls.hasOwnProperty(l)) {
|
|
@@ -2411,40 +2411,40 @@ class J {
|
|
|
2411
2411
|
o.telnyx_call_control_id && (B.telnyxCallControlId = o.telnyx_call_control_id), o.telnyx_session_id && (B.telnyxSessionId = o.telnyx_session_id), o.telnyx_leg_id && (B.telnyxLegId = o.telnyx_leg_id), o.client_state && (B.clientState = o.client_state), o.dialogParams && o.dialogParams.custom_headers && o.dialogParams.custom_headers.length && (B.customHeaders = o.dialogParams.custom_headers);
|
|
2412
2412
|
const x = new he(i, B);
|
|
2413
2413
|
return x.nodeId = this.nodeId, x;
|
|
2414
|
-
}, k = new
|
|
2414
|
+
}, k = new en(d), p = new tn(d);
|
|
2415
2415
|
switch (r) {
|
|
2416
|
-
case
|
|
2416
|
+
case F.Ping:
|
|
2417
2417
|
this.session.setPingReceived(), this.session.execute(p).then((() => {
|
|
2418
2418
|
J.receivedAuthenticationRequired = 0;
|
|
2419
2419
|
})).catch(((E) => L(this, void 0, void 0, (function* () {
|
|
2420
2420
|
E.code === this.session.authenticationRequiredErrorCode && J.receivedAuthenticationRequired >= 0 && (J.receivedAuthenticationRequired += 1, J.receivedAuthenticationRequired > 1 && this.session.hasAutoReconnect() && (y.warn("Ping failed twice with Authentication Required. Re-logging in..."), Ne(this.session.options) ? this.handleLogin() : Ie(this.session.options) && this.handleAnonymousLogin(), J.receivedAuthenticationRequired = -1));
|
|
2421
2421
|
}))));
|
|
2422
2422
|
break;
|
|
2423
|
-
case
|
|
2423
|
+
case F.Punt:
|
|
2424
2424
|
i.disconnect();
|
|
2425
2425
|
break;
|
|
2426
|
-
case
|
|
2426
|
+
case F.Invite: {
|
|
2427
2427
|
const E = C();
|
|
2428
2428
|
E.playRingtone(), E.setState(N.Ringing), E.direction = de.Inbound, this._ack(s, r);
|
|
2429
2429
|
break;
|
|
2430
2430
|
}
|
|
2431
|
-
case
|
|
2432
|
-
if (w) return void this.session.execute(new rt({ sessid: this.session.sessionid, sdp: this.session.calls[l].peer.instance.localDescription.sdp, dialogParams: this.session.calls[l].options, "User-Agent": `Web-${
|
|
2431
|
+
case F.Attach: {
|
|
2432
|
+
if (w) return void this.session.execute(new rt({ sessid: this.session.sessionid, sdp: this.session.calls[l].peer.instance.localDescription.sdp, dialogParams: this.session.calls[l].options, "User-Agent": `Web-${fi}` }));
|
|
2433
2433
|
y.info(`[${(/* @__PURE__ */ new Date()).toISOString()}][${l}] Re-creating call instance.`);
|
|
2434
2434
|
const E = C();
|
|
2435
2435
|
this.session.autoRecoverCalls ? E.answer() : E.setState(N.Recovering), E.handleMessage(e);
|
|
2436
2436
|
break;
|
|
2437
2437
|
}
|
|
2438
|
-
case
|
|
2438
|
+
case F.Event:
|
|
2439
2439
|
case "webrtc.event":
|
|
2440
2440
|
if (!h) return void y.error("Verto received an unknown event:", o);
|
|
2441
2441
|
const S = i.relayProtocol, A = h.split(".")[0];
|
|
2442
|
-
i._existsSubscription(S, h) ?
|
|
2442
|
+
i._existsSubscription(S, h) ? $(S, o, h) : h === i.sessionid ? this._handleSessionEvent(o.eventData) : i._existsSubscription(S, A) ? $(S, o, A) : i.calls.hasOwnProperty(h) ? i.calls[h].handleMessage(e) : $(O.Notification, o, i.uuid);
|
|
2443
2443
|
break;
|
|
2444
|
-
case
|
|
2445
|
-
o.type = oe.generic,
|
|
2444
|
+
case F.Info:
|
|
2445
|
+
o.type = oe.generic, $(O.Notification, o, i.uuid);
|
|
2446
2446
|
break;
|
|
2447
|
-
case
|
|
2447
|
+
case F.ClientReady:
|
|
2448
2448
|
this.session.execute(k);
|
|
2449
2449
|
break;
|
|
2450
2450
|
default: {
|
|
@@ -2453,14 +2453,14 @@ class J {
|
|
|
2453
2453
|
switch (E) {
|
|
2454
2454
|
case te.REGISTER:
|
|
2455
2455
|
case te.REGED:
|
|
2456
|
-
i.connection.previousGatewayState !== te.REGED && i.connection.previousGatewayState !== te.REGISTER && (this.session._triggerKeepAliveTimeoutCheck(), J.retriedRegister = 0, o.type = oe.vertoClientReady,
|
|
2456
|
+
i.connection.previousGatewayState !== te.REGED && i.connection.previousGatewayState !== te.REGISTER && (this.session._triggerKeepAliveTimeoutCheck(), J.retriedRegister = 0, o.type = oe.vertoClientReady, $(O.Ready, o, i.uuid), i.options.trickleIce && (y.debug("Trickle ICE is enabled. Checking Gateway support"), this.session.execute(new rn({ candidate: "" })).catch(((P) => {
|
|
2457
2457
|
P.code === this.session.invalidMethodErrorCode ? (y.warn("Trickle ICE is not supported by the server, disabling it."), y.debug("Trickle ICE check error:", JSON.stringify(P, null, 2)), i.options.trickleIce = !1) : y.debug("Trickle ICE check:", JSON.stringify(P, null, 2));
|
|
2458
2458
|
}))));
|
|
2459
2459
|
break;
|
|
2460
2460
|
case te.UNREGED:
|
|
2461
2461
|
case te.NOREG:
|
|
2462
2462
|
if (J.retriedRegister += 1, J.retriedRegister === 5) {
|
|
2463
|
-
J.retriedRegister = 0,
|
|
2463
|
+
J.retriedRegister = 0, $(O.Error, { error: new Mt("Fail to register the user, the server tried 5 times", "UNREGED|NOREG"), sessionId: i.sessionid }, i.uuid);
|
|
2464
2464
|
break;
|
|
2465
2465
|
}
|
|
2466
2466
|
setTimeout((() => {
|
|
@@ -2471,11 +2471,11 @@ class J {
|
|
|
2471
2471
|
case te.FAIL_WAIT:
|
|
2472
2472
|
if (i.connection.previousGatewayState !== te.FAILED && i.connection.previousGatewayState !== te.FAIL_WAIT) {
|
|
2473
2473
|
if (!this.session.hasAutoReconnect()) {
|
|
2474
|
-
J.retriedConnect = 0,
|
|
2474
|
+
J.retriedConnect = 0, $(O.Error, { error: new Mt("Fail to connect the server, the server tried 5 times", "FAILED|FAIL_WAIT"), sessionId: i.sessionid }, i.uuid);
|
|
2475
2475
|
break;
|
|
2476
2476
|
}
|
|
2477
2477
|
if (J.retriedConnect += 1, J.retriedConnect === 5) {
|
|
2478
|
-
J.retriedConnect = 0,
|
|
2478
|
+
J.retriedConnect = 0, $(O.Error, { error: new Error("Connection Retry Failed"), sessionId: i.sessionid }, i.uuid);
|
|
2479
2479
|
break;
|
|
2480
2480
|
}
|
|
2481
2481
|
setTimeout((() => {
|
|
@@ -2531,7 +2531,7 @@ class J {
|
|
|
2531
2531
|
const { callId: k = null } = n.subscriptions[i][r];
|
|
2532
2532
|
if (w = n.calls[k] || null, k !== null) {
|
|
2533
2533
|
const p = { type: oe.conferenceUpdate, action: se.Leave, conferenceName: o, participantId: Number(f), role: v };
|
|
2534
|
-
|
|
2534
|
+
$(O.Notification, p, k, !1) || $(O.Notification, p, n.uuid), w === null && ue(O.Notification, null, k);
|
|
2535
2535
|
}
|
|
2536
2536
|
}
|
|
2537
2537
|
const C = [r, d, l, h];
|
|
@@ -2549,26 +2549,26 @@ class J {
|
|
|
2549
2549
|
switch (e.contentType) {
|
|
2550
2550
|
case "layout-info":
|
|
2551
2551
|
case "layer-info":
|
|
2552
|
-
|
|
2552
|
+
cn(this.session, e);
|
|
2553
2553
|
break;
|
|
2554
2554
|
case "logo-info": {
|
|
2555
2555
|
const n = { type: oe.conferenceUpdate, action: se.LogoInfo, logo: e.logoURL };
|
|
2556
|
-
|
|
2556
|
+
$(O.Notification, n, this.session.uuid);
|
|
2557
2557
|
break;
|
|
2558
2558
|
}
|
|
2559
2559
|
}
|
|
2560
2560
|
}
|
|
2561
2561
|
}
|
|
2562
2562
|
J.retriedConnect = 0, J.retriedRegister = 0, J.receivedAuthenticationRequired = 0;
|
|
2563
|
-
class
|
|
2563
|
+
class gi extends pi {
|
|
2564
2564
|
constructor(e) {
|
|
2565
2565
|
super(e), this.relayProtocol = "verto-protocol", this.timeoutErrorCode = -329990, this.handleLoginOnSocketOpen = () => L(this, void 0, void 0, (function* () {
|
|
2566
2566
|
this._idle = !1;
|
|
2567
|
-
const { login: n, password: i, passwd: s, login_token: r, userVariables: o, autoReconnect: d = !0 } = this.options, l = new
|
|
2567
|
+
const { login: n, password: i, passwd: s, login_token: r, userVariables: o, autoReconnect: d = !0 } = this.options, l = new on(n, i || s, r, this.sessionid, o, !!fe()), h = yield this.execute(l).catch(this._handleLoginError);
|
|
2568
2568
|
h && (this._autoReconnect = d, this.sessionid = h.sessid);
|
|
2569
2569
|
})), this.handleAnonymousLoginOnSocketOpen = () => L(this, void 0, void 0, (function* () {
|
|
2570
2570
|
this._idle = !1;
|
|
2571
|
-
const { anonymous_login: n } = this.options, i = new
|
|
2571
|
+
const { anonymous_login: n } = this.options, i = new ln({ target_id: n.target_id, target_type: n.target_type, target_version_id: n.target_version_id, sessionId: this.sessionid, userVariables: this.options.userVariables, reconnection: !!fe() }), s = yield this.execute(i).catch(this._handleLoginError);
|
|
2572
2572
|
s && (this.sessionid = s.sessid);
|
|
2573
2573
|
})), window.addEventListener("beforeunload", ((n) => {
|
|
2574
2574
|
this.calls && Object.keys(this.calls).forEach(((i) => {
|
|
@@ -2606,25 +2606,25 @@ class fi extends hi {
|
|
|
2606
2606
|
new J(this).handleMessage(e);
|
|
2607
2607
|
}
|
|
2608
2608
|
}
|
|
2609
|
-
class
|
|
2609
|
+
class vi extends gi {
|
|
2610
2610
|
constructor(e) {
|
|
2611
|
-
super(e), y.info(`SDK version: ${
|
|
2611
|
+
super(e), y.info(`SDK version: ${sn}`);
|
|
2612
2612
|
}
|
|
2613
2613
|
newCall(e) {
|
|
2614
2614
|
return super.newCall(e);
|
|
2615
2615
|
}
|
|
2616
2616
|
static webRTCInfo() {
|
|
2617
|
-
return
|
|
2617
|
+
return Qn();
|
|
2618
2618
|
}
|
|
2619
2619
|
static webRTCSupportedBrowserList() {
|
|
2620
2620
|
return [{ operationSystem: "Android", supported: [{ browserName: "Chrome", features: ["audio"], supported: H.full }, { browserName: "Firefox", features: ["audio"], supported: H.partial }, { browserName: "Safari", supported: H.not_supported }, { browserName: "Edge", supported: H.not_supported }] }, { operationSystem: "iOS", supported: [{ browserName: "Chrome", supported: H.not_supported }, { browserName: "Firefox", supported: H.not_supported }, { browserName: "Safari", features: ["video", "audio"], supported: H.full }, { browserName: "Edge", supported: H.not_supported }] }, { operationSystem: "Linux", supported: [{ browserName: "Chrome", features: ["video", "audio"], supported: H.full }, { browserName: "Firefox", features: ["audio"], supported: H.partial }, { browserName: "Safari", supported: H.not_supported }, { browserName: "Edge", supported: H.not_supported }] }, { operationSystem: "MacOS", supported: [{ browserName: "Chrome", features: ["video", "audio"], supported: H.full }, { browserName: "Firefox", features: ["audio"], supported: H.partial }, { browserName: "Safari", features: ["video", "audio"], supported: H.full }, { browserName: "Edge", features: ["audio"], supported: H.partial }] }, { operationSystem: "Windows", supported: [{ browserName: "Chrome", features: ["video", "audio"], supported: H.full }, { browserName: "Firefox", features: ["audio"], supported: H.partial }, { browserName: "Safari", supported: H.not_supported }, { browserName: "Edge", features: ["audio"], supported: H.partial }] }];
|
|
2621
2621
|
}
|
|
2622
2622
|
}
|
|
2623
|
-
function
|
|
2623
|
+
function un(t) {
|
|
2624
2624
|
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
2625
2625
|
}
|
|
2626
2626
|
var Xe = { exports: {} }, Pt;
|
|
2627
|
-
function
|
|
2627
|
+
function mi() {
|
|
2628
2628
|
return Pt || (Pt = 1, (function(t) {
|
|
2629
2629
|
var e = Object.prototype.hasOwnProperty, n = "~";
|
|
2630
2630
|
function i() {
|
|
@@ -2730,14 +2730,14 @@ function vi() {
|
|
|
2730
2730
|
}, d.prototype.off = d.prototype.removeListener, d.prototype.addListener = d.prototype.on, d.prefixed = n, d.EventEmitter = d, t.exports = d;
|
|
2731
2731
|
})(Xe)), Xe.exports;
|
|
2732
2732
|
}
|
|
2733
|
-
var
|
|
2734
|
-
const gt = /* @__PURE__ */
|
|
2735
|
-
var Pe = { exports: {} },
|
|
2736
|
-
function
|
|
2733
|
+
var yi = mi();
|
|
2734
|
+
const gt = /* @__PURE__ */ un(yi), $e = new gt();
|
|
2735
|
+
var Pe = { exports: {} }, bi = Pe.exports, Dt;
|
|
2736
|
+
function _i() {
|
|
2737
2737
|
return Dt || (Dt = 1, (function(t) {
|
|
2738
2738
|
(function(e, n) {
|
|
2739
2739
|
t.exports ? t.exports = n() : e.log = n();
|
|
2740
|
-
})(
|
|
2740
|
+
})(bi, function() {
|
|
2741
2741
|
var e = function() {
|
|
2742
2742
|
}, n = "undefined", i = typeof window !== n && typeof window.navigator !== n && /Trident\/|MSIE /.test(window.navigator.userAgent), s = [
|
|
2743
2743
|
"trace",
|
|
@@ -2880,25 +2880,25 @@ function bi() {
|
|
|
2880
2880
|
});
|
|
2881
2881
|
})(Pe)), Pe.exports;
|
|
2882
2882
|
}
|
|
2883
|
-
var
|
|
2884
|
-
const
|
|
2883
|
+
var Si = _i();
|
|
2884
|
+
const wi = /* @__PURE__ */ un(Si), Ci = () => (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").replace("Z", ""), z = wi.getLogger("telnyx-ai-agent"), ki = z.methodFactory;
|
|
2885
2885
|
z.methodFactory = (t, e, n) => {
|
|
2886
|
-
const i =
|
|
2886
|
+
const i = ki(t, e, n);
|
|
2887
2887
|
return function(...s) {
|
|
2888
|
-
i(
|
|
2888
|
+
i(Ci(), "-", ...s);
|
|
2889
2889
|
};
|
|
2890
2890
|
};
|
|
2891
2891
|
z.setLevel("info");
|
|
2892
|
-
function
|
|
2892
|
+
function Ii(t, e) {
|
|
2893
2893
|
let n = 0;
|
|
2894
2894
|
return (...i) => {
|
|
2895
2895
|
const s = Date.now();
|
|
2896
2896
|
s - n >= e && (n = s, t(...i));
|
|
2897
2897
|
};
|
|
2898
2898
|
}
|
|
2899
|
-
const Ze = 10,
|
|
2899
|
+
const Ze = 10, Ei = 1e3, Nt = 20;
|
|
2900
2900
|
class Ti {
|
|
2901
|
-
|
|
2901
|
+
remoteIntervalId = null;
|
|
2902
2902
|
localIntervalId = null;
|
|
2903
2903
|
remoteStream = null;
|
|
2904
2904
|
localStream = null;
|
|
@@ -2915,8 +2915,8 @@ class Ti {
|
|
|
2915
2915
|
lastUserAudioTime = null;
|
|
2916
2916
|
constructor() {
|
|
2917
2917
|
}
|
|
2918
|
-
updateAgentState =
|
|
2919
|
-
z.debug("AudioStreamMonitor updateAgentState", e), z.debug("Previous state:", this.lastState), e.state !== this.lastState && (this.lastState = e.state,
|
|
2918
|
+
updateAgentState = Ii((e) => {
|
|
2919
|
+
z.debug("AudioStreamMonitor updateAgentState", e), z.debug("Previous state:", this.lastState), e.state !== this.lastState && (this.lastState = e.state, $e.emit("conversation.agent.state", e));
|
|
2920
2920
|
}, 100);
|
|
2921
2921
|
/**
|
|
2922
2922
|
* Set the remote audio stream (agent's voice) to monitor for speech detection
|
|
@@ -2935,7 +2935,7 @@ class Ti {
|
|
|
2935
2935
|
this.setRemoteStream(e);
|
|
2936
2936
|
}
|
|
2937
2937
|
stopRemoteMonitor() {
|
|
2938
|
-
this.
|
|
2938
|
+
this.remoteIntervalId && (clearInterval(this.remoteIntervalId), this.remoteIntervalId = null), this.remoteSource?.disconnect(), this.remoteAudioContext?.close(), this.remoteAudioContext = null, this.remoteSource = null, this.remoteAnalyser = null;
|
|
2939
2939
|
}
|
|
2940
2940
|
stopLocalMonitor() {
|
|
2941
2941
|
this.localIntervalId && (clearInterval(this.localIntervalId), this.localIntervalId = null), this.localSource?.disconnect(), this.localAudioContext?.close(), this.localAudioContext = null, this.localSource = null, this.localAnalyser = null;
|
|
@@ -2972,9 +2972,9 @@ class Ti {
|
|
|
2972
2972
|
this.updateAgentState({ state: "speaking" });
|
|
2973
2973
|
else
|
|
2974
2974
|
this.thinkingStartTime === null && this.updateAgentState({ state: "listening" });
|
|
2975
|
-
i = o
|
|
2975
|
+
i = o;
|
|
2976
2976
|
};
|
|
2977
|
-
this.
|
|
2977
|
+
this.remoteIntervalId = window.setInterval(s, Nt);
|
|
2978
2978
|
}
|
|
2979
2979
|
/**
|
|
2980
2980
|
* Monitor local stream (user's microphone) for VAD
|
|
@@ -2997,13 +2997,13 @@ class Ti {
|
|
|
2997
2997
|
this.userIsSpeaking = !0, this.lastUserAudioTime = performance.now();
|
|
2998
2998
|
else if (s && this.userIsSpeaking)
|
|
2999
2999
|
this.lastUserAudioTime = performance.now();
|
|
3000
|
-
else if (!s && this.userIsSpeaking && this.lastUserAudioTime !== null && performance.now() - this.lastUserAudioTime >
|
|
3000
|
+
else if (!s && this.userIsSpeaking && this.lastUserAudioTime !== null && performance.now() - this.lastUserAudioTime > Ei) {
|
|
3001
3001
|
this.userIsSpeaking = !1, this.thinkingStartTime = performance.now();
|
|
3002
3002
|
const o = (/* @__PURE__ */ new Date()).toISOString();
|
|
3003
3003
|
this.updateAgentState({ state: "thinking", thinkingStartedAt: o });
|
|
3004
3004
|
}
|
|
3005
3005
|
};
|
|
3006
|
-
this.localIntervalId = window.setInterval(n,
|
|
3006
|
+
this.localIntervalId = window.setInterval(n, Nt);
|
|
3007
3007
|
}
|
|
3008
3008
|
destroy() {
|
|
3009
3009
|
this.stopAudioStreamMonitor();
|
|
@@ -3058,7 +3058,7 @@ class Mi extends gt {
|
|
|
3058
3058
|
switch (e.params.type) {
|
|
3059
3059
|
case "response.text.delta": {
|
|
3060
3060
|
const n = Oi(e);
|
|
3061
|
-
n && (this.transcript.push(n), this.emit("transcript.item", n),
|
|
3061
|
+
n && (this.transcript.push(n), this.emit("transcript.item", n), $e.emit("conversation.agent.state", { state: "listening" }));
|
|
3062
3062
|
return;
|
|
3063
3063
|
}
|
|
3064
3064
|
case "conversation.item.created": {
|
|
@@ -3069,7 +3069,7 @@ class Mi extends gt {
|
|
|
3069
3069
|
}
|
|
3070
3070
|
};
|
|
3071
3071
|
}
|
|
3072
|
-
class
|
|
3072
|
+
class jt extends gt {
|
|
3073
3073
|
telnyxRTC;
|
|
3074
3074
|
transcription;
|
|
3075
3075
|
agentId;
|
|
@@ -3078,7 +3078,7 @@ class Nt extends gt {
|
|
|
3078
3078
|
audioStreamMonitor;
|
|
3079
3079
|
activeCall;
|
|
3080
3080
|
constructor(e) {
|
|
3081
|
-
super(), this.agentId = e.agentId, this.versionId = e.versionId || "main", this.debug = e.debug || !1, this.activeCall = null, z.setLevel(this.debug ? "debug" : "info"), this.telnyxRTC = new
|
|
3081
|
+
super(), this.agentId = e.agentId, this.versionId = e.versionId || "main", this.debug = e.debug || !1, this.activeCall = null, z.setLevel(this.debug ? "debug" : "info"), this.telnyxRTC = new vi({
|
|
3082
3082
|
// @ts-expect-error hidden argument
|
|
3083
3083
|
environment: e.environment || "production",
|
|
3084
3084
|
anonymous_login: {
|
|
@@ -3088,7 +3088,7 @@ class Nt extends gt {
|
|
|
3088
3088
|
},
|
|
3089
3089
|
debug: e.debug || !1,
|
|
3090
3090
|
trickleIce: e.trickleIce
|
|
3091
|
-
}), this.telnyxRTC.on(O.Ready, this.onClientReady), this.telnyxRTC.on(O.Error, this.onClientOrSocketError), this.telnyxRTC.on(O.SocketError, this.onClientOrSocketError), this.telnyxRTC.on(O.Notification, this.onNotification), this.transcription = new Mi(this.telnyxRTC), this.transcription.addListener("transcript.item", this.onTranscriptItem),
|
|
3091
|
+
}), this.telnyxRTC.on(O.Ready, this.onClientReady), this.telnyxRTC.on(O.Error, this.onClientOrSocketError), this.telnyxRTC.on(O.SocketError, this.onClientOrSocketError), this.telnyxRTC.on(O.Notification, this.onNotification), this.transcription = new Mi(this.telnyxRTC), this.transcription.addListener("transcript.item", this.onTranscriptItem), $e.addListener(
|
|
3092
3092
|
"conversation.agent.state",
|
|
3093
3093
|
this.onAgentStateChange
|
|
3094
3094
|
), this.audioStreamMonitor = new Ti();
|
|
@@ -3106,7 +3106,7 @@ class Nt extends gt {
|
|
|
3106
3106
|
* Emits an 'agent.disconnected' event before completing cleanup.
|
|
3107
3107
|
*/
|
|
3108
3108
|
async disconnect() {
|
|
3109
|
-
this.audioStreamMonitor.destroy(), this.telnyxRTC.disconnect(), this.telnyxRTC.off(O.Ready, this.onClientReady), this.telnyxRTC.off(O.Error, this.onClientOrSocketError), this.telnyxRTC.off(O.SocketError, this.onClientOrSocketError), this.telnyxRTC.off(O.Notification, this.onNotification), this.emit("agent.disconnected"), this.transcription.removeAllListeners(),
|
|
3109
|
+
this.audioStreamMonitor.destroy(), this.telnyxRTC.disconnect(), this.telnyxRTC.off(O.Ready, this.onClientReady), this.telnyxRTC.off(O.Error, this.onClientOrSocketError), this.telnyxRTC.off(O.SocketError, this.onClientOrSocketError), this.telnyxRTC.off(O.Notification, this.onNotification), this.emit("agent.disconnected"), this.transcription.removeAllListeners(), $e.removeAllListeners(), this.removeAllListeners();
|
|
3110
3110
|
}
|
|
3111
3111
|
/**
|
|
3112
3112
|
* Sends a text message to the AI agent during an active conversation.
|
|
@@ -3180,7 +3180,7 @@ class Nt extends gt {
|
|
|
3180
3180
|
const l = this.telnyxRTC.newCall({
|
|
3181
3181
|
destinationNumber: "xxx",
|
|
3182
3182
|
...o,
|
|
3183
|
-
audio: r,
|
|
3183
|
+
audio: r ?? !0,
|
|
3184
3184
|
preferred_codecs: [i],
|
|
3185
3185
|
customHeaders: d.length > 0 ? d : void 0
|
|
3186
3186
|
});
|
|
@@ -3221,10 +3221,10 @@ class Nt extends gt {
|
|
|
3221
3221
|
};
|
|
3222
3222
|
}
|
|
3223
3223
|
var Me = { exports: {} }, _e = {};
|
|
3224
|
-
var
|
|
3224
|
+
var Ut;
|
|
3225
3225
|
function Pi() {
|
|
3226
|
-
if (
|
|
3227
|
-
|
|
3226
|
+
if (Ut) return _e;
|
|
3227
|
+
Ut = 1;
|
|
3228
3228
|
var t = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
|
|
3229
3229
|
function n(i, s, r) {
|
|
3230
3230
|
var o = null;
|
|
@@ -3244,9 +3244,9 @@ function Pi() {
|
|
|
3244
3244
|
return _e.Fragment = e, _e.jsx = n, _e.jsxs = n, _e;
|
|
3245
3245
|
}
|
|
3246
3246
|
var Se = {};
|
|
3247
|
-
var
|
|
3247
|
+
var $t;
|
|
3248
3248
|
function Di() {
|
|
3249
|
-
return
|
|
3249
|
+
return $t || ($t = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
3250
3250
|
function t(m) {
|
|
3251
3251
|
if (m == null) return null;
|
|
3252
3252
|
if (typeof m == "function")
|
|
@@ -3401,8 +3401,8 @@ function Di() {
|
|
|
3401
3401
|
else v(W);
|
|
3402
3402
|
if (b.call(M, "key")) {
|
|
3403
3403
|
W = t(m);
|
|
3404
|
-
var re = Object.keys(M).filter(function(
|
|
3405
|
-
return
|
|
3404
|
+
var re = Object.keys(M).filter(function(En) {
|
|
3405
|
+
return En !== "key";
|
|
3406
3406
|
});
|
|
3407
3407
|
V = 0 < re.length ? "{key: someKey, " + re.join(": ..., ") + ": ...}" : "{key: someKey}", G[W + V] || (re = 0 < re.length ? "{" + re.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
3408
3408
|
`A props object containing a "key" prop is being spread into JSX:
|
|
@@ -3481,16 +3481,16 @@ function Ni() {
|
|
|
3481
3481
|
}
|
|
3482
3482
|
var we = Ni();
|
|
3483
3483
|
const ce = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 };
|
|
3484
|
-
function
|
|
3484
|
+
function hn(t) {
|
|
3485
3485
|
return "init" in t;
|
|
3486
3486
|
}
|
|
3487
3487
|
function at(t) {
|
|
3488
3488
|
return !!t.write;
|
|
3489
3489
|
}
|
|
3490
|
-
function
|
|
3490
|
+
function Bt(t) {
|
|
3491
3491
|
return "v" in t || "e" in t;
|
|
3492
3492
|
}
|
|
3493
|
-
function
|
|
3493
|
+
function Fe(t) {
|
|
3494
3494
|
if ("e" in t)
|
|
3495
3495
|
throw t.e;
|
|
3496
3496
|
if ((ce ? "production" : void 0) !== "production" && !("v" in t))
|
|
@@ -3498,7 +3498,7 @@ function $e(t) {
|
|
|
3498
3498
|
return t.v;
|
|
3499
3499
|
}
|
|
3500
3500
|
const Be = /* @__PURE__ */ new WeakMap();
|
|
3501
|
-
function
|
|
3501
|
+
function pn(t) {
|
|
3502
3502
|
var e;
|
|
3503
3503
|
return Ve(t) && !!((e = Be.get(t)) != null && e[0]);
|
|
3504
3504
|
}
|
|
@@ -3520,14 +3520,14 @@ function ct(t, e) {
|
|
|
3520
3520
|
function Ve(t) {
|
|
3521
3521
|
return typeof t?.then == "function";
|
|
3522
3522
|
}
|
|
3523
|
-
function
|
|
3523
|
+
function fn(t, e, n) {
|
|
3524
3524
|
if (!n.p.has(t)) {
|
|
3525
3525
|
n.p.add(t);
|
|
3526
3526
|
const i = () => n.p.delete(t);
|
|
3527
3527
|
e.then(i, i);
|
|
3528
3528
|
}
|
|
3529
3529
|
}
|
|
3530
|
-
function
|
|
3530
|
+
function gn(t, e, n) {
|
|
3531
3531
|
var i;
|
|
3532
3532
|
const s = /* @__PURE__ */ new Set();
|
|
3533
3533
|
for (const r of ((i = n.get(t)) == null ? void 0 : i.t) || [])
|
|
@@ -3536,7 +3536,7 @@ function fn(t, e, n) {
|
|
|
3536
3536
|
s.add(r);
|
|
3537
3537
|
return s;
|
|
3538
3538
|
}
|
|
3539
|
-
const Ui = (t, e, ...n) => e.read(...n),
|
|
3539
|
+
const Ui = (t, e, ...n) => e.read(...n), $i = (t, e, ...n) => e.write(...n), Fi = (t, e) => {
|
|
3540
3540
|
if (e.INTERNAL_onInit)
|
|
3541
3541
|
return e.INTERNAL_onInit(t);
|
|
3542
3542
|
if (e.unstable_onInit)
|
|
@@ -3588,7 +3588,7 @@ const Ui = (t, e, ...n) => e.read(...n), Fi = (t, e, ...n) => e.write(...n), $i
|
|
|
3588
3588
|
continue;
|
|
3589
3589
|
}
|
|
3590
3590
|
h.add(_);
|
|
3591
|
-
for (const C of
|
|
3591
|
+
for (const C of gn(_, w, n))
|
|
3592
3592
|
h.has(C) || v.push(C);
|
|
3593
3593
|
}
|
|
3594
3594
|
for (let _ = l.length - 1; _ >= 0; --_) {
|
|
@@ -3604,7 +3604,7 @@ const Ui = (t, e, ...n) => e.read(...n), Fi = (t, e, ...n) => e.write(...n), $i
|
|
|
3604
3604
|
}, dt = /* @__PURE__ */ new WeakSet(), Hi = (t, e) => {
|
|
3605
3605
|
var n, i;
|
|
3606
3606
|
const s = X(t), r = s[1], o = s[2], d = s[3], l = s[6], h = s[7], f = s[11], v = s[12], _ = s[13], w = s[14], C = s[16], k = s[17], p = f(t, e);
|
|
3607
|
-
if (
|
|
3607
|
+
if (Bt(p)) {
|
|
3608
3608
|
if (r.has(e) && o.get(e) !== p.n)
|
|
3609
3609
|
return p;
|
|
3610
3610
|
let x = !1;
|
|
@@ -3625,18 +3625,18 @@ const Ui = (t, e, ...n) => e.read(...n), Fi = (t, e, ...n) => e.write(...n), $i
|
|
|
3625
3625
|
var a;
|
|
3626
3626
|
if (x === e) {
|
|
3627
3627
|
const u = f(t, x);
|
|
3628
|
-
if (
|
|
3629
|
-
if (
|
|
3628
|
+
if (!Bt(u))
|
|
3629
|
+
if (hn(x))
|
|
3630
3630
|
Ge(t, x, x.init);
|
|
3631
3631
|
else
|
|
3632
3632
|
throw new Error("no atom init");
|
|
3633
|
-
return
|
|
3633
|
+
return Fe(u);
|
|
3634
3634
|
}
|
|
3635
3635
|
const c = w(t, x);
|
|
3636
3636
|
try {
|
|
3637
|
-
return
|
|
3637
|
+
return Fe(c);
|
|
3638
3638
|
} finally {
|
|
3639
|
-
p.d.set(x, c.n),
|
|
3639
|
+
p.d.set(x, c.n), pn(p.v) && fn(e, p.v, c), r.has(e) && ((a = r.get(x)) == null || a.t.add(e)), S || A();
|
|
3640
3640
|
}
|
|
3641
3641
|
}
|
|
3642
3642
|
let P, D;
|
|
@@ -3670,27 +3670,27 @@ const Ui = (t, e, ...n) => e.read(...n), Fi = (t, e, ...n) => e.write(...n), $i
|
|
|
3670
3670
|
const n = X(t), i = n[1], s = n[2], r = n[11], o = [e];
|
|
3671
3671
|
for (; o.length; ) {
|
|
3672
3672
|
const d = o.pop(), l = r(t, d);
|
|
3673
|
-
for (const h of
|
|
3673
|
+
for (const h of gn(d, l, i)) {
|
|
3674
3674
|
const f = r(t, h);
|
|
3675
3675
|
s.set(h, f.n), o.push(h);
|
|
3676
3676
|
}
|
|
3677
3677
|
}
|
|
3678
|
-
},
|
|
3678
|
+
}, vn = (t, e, ...n) => {
|
|
3679
3679
|
const i = X(t), s = i[3], r = i[6], o = i[8], d = i[11], l = i[12], h = i[13], f = i[14], v = i[15], _ = i[17];
|
|
3680
3680
|
let w = !0;
|
|
3681
|
-
const C = (p) =>
|
|
3681
|
+
const C = (p) => Fe(f(t, p)), k = (p, ...S) => {
|
|
3682
3682
|
var A;
|
|
3683
3683
|
const E = d(t, p);
|
|
3684
3684
|
try {
|
|
3685
3685
|
if (p === e) {
|
|
3686
|
-
if (!
|
|
3686
|
+
if (!hn(p))
|
|
3687
3687
|
throw new Error("atom not writable");
|
|
3688
3688
|
(ce ? "production" : void 0) !== "production" && dt.add(t);
|
|
3689
3689
|
const P = E.n, D = S[0];
|
|
3690
3690
|
Ge(t, p, D), _(t, p), P !== E.n && (s.add(p), v(t, p), (A = r.c) == null || A.call(r, p));
|
|
3691
3691
|
return;
|
|
3692
3692
|
} else
|
|
3693
|
-
return
|
|
3693
|
+
return vn(t, p, ...S);
|
|
3694
3694
|
} finally {
|
|
3695
3695
|
w || (h(t), l(t));
|
|
3696
3696
|
}
|
|
@@ -3703,7 +3703,7 @@ const Ui = (t, e, ...n) => e.read(...n), Fi = (t, e, ...n) => e.write(...n), $i
|
|
|
3703
3703
|
}, Ji = (t, e) => {
|
|
3704
3704
|
var n;
|
|
3705
3705
|
const i = X(t), s = i[1], r = i[3], o = i[6], d = i[11], l = i[15], h = i[18], f = i[19], v = d(t, e), _ = s.get(e);
|
|
3706
|
-
if (_ && !
|
|
3706
|
+
if (_ && !pn(v.v)) {
|
|
3707
3707
|
for (const [w, C] of v.d)
|
|
3708
3708
|
if (!_.d.has(w)) {
|
|
3709
3709
|
const k = d(t, w);
|
|
@@ -3716,14 +3716,14 @@ const Ui = (t, e, ...n) => e.read(...n), Fi = (t, e, ...n) => e.write(...n), $i
|
|
|
3716
3716
|
C?.t.delete(e);
|
|
3717
3717
|
}
|
|
3718
3718
|
}
|
|
3719
|
-
},
|
|
3719
|
+
}, mn = (t, e) => {
|
|
3720
3720
|
var n;
|
|
3721
3721
|
const i = X(t), s = i[1], r = i[4], o = i[6], d = i[10], l = i[11], h = i[12], f = i[13], v = i[14], _ = i[16], w = l(t, e);
|
|
3722
3722
|
let C = s.get(e);
|
|
3723
3723
|
if (!C) {
|
|
3724
3724
|
v(t, e);
|
|
3725
3725
|
for (const k of w.d.keys())
|
|
3726
|
-
|
|
3726
|
+
mn(t, k).t.add(e);
|
|
3727
3727
|
if (C = {
|
|
3728
3728
|
l: /* @__PURE__ */ new Set(),
|
|
3729
3729
|
d: new Set(w.d.keys()),
|
|
@@ -3783,7 +3783,7 @@ const Ui = (t, e, ...n) => e.read(...n), Fi = (t, e, ...n) => e.write(...n), $i
|
|
|
3783
3783
|
const i = X(t)[11], s = i(t, e), r = "v" in s, o = s.v;
|
|
3784
3784
|
if (Ve(n))
|
|
3785
3785
|
for (const d of s.d.keys())
|
|
3786
|
-
|
|
3786
|
+
fn(
|
|
3787
3787
|
e,
|
|
3788
3788
|
n,
|
|
3789
3789
|
i(t, d)
|
|
@@ -3791,7 +3791,7 @@ const Ui = (t, e, ...n) => e.read(...n), Fi = (t, e, ...n) => e.write(...n), $i
|
|
|
3791
3791
|
s.v = n, delete s.e, (!r || !Object.is(o, s.v)) && (++s.n, Ve(o) && ji(o));
|
|
3792
3792
|
}, zi = (t, e) => {
|
|
3793
3793
|
const n = X(t)[14];
|
|
3794
|
-
return
|
|
3794
|
+
return Fe(n(t, e));
|
|
3795
3795
|
}, Ki = (t, e, ...n) => {
|
|
3796
3796
|
const i = X(t), s = i[12], r = i[13], o = i[16];
|
|
3797
3797
|
try {
|
|
@@ -3804,8 +3804,8 @@ const Ui = (t, e, ...n) => e.read(...n), Fi = (t, e, ...n) => e.write(...n), $i
|
|
|
3804
3804
|
return l.add(n), s(t), () => {
|
|
3805
3805
|
l.delete(n), o(t, e), s(t);
|
|
3806
3806
|
};
|
|
3807
|
-
},
|
|
3808
|
-
const e =
|
|
3807
|
+
}, yn = /* @__PURE__ */ new WeakMap(), X = (t) => {
|
|
3808
|
+
const e = yn.get(t);
|
|
3809
3809
|
if ((ce ? "production" : void 0) !== "production" && !e)
|
|
3810
3810
|
throw new Error(
|
|
3811
3811
|
"Store must be created by buildStore to read its building blocks"
|
|
@@ -3844,8 +3844,8 @@ function Xi(...t) {
|
|
|
3844
3844
|
// storeHooks
|
|
3845
3845
|
// atom interceptors
|
|
3846
3846
|
Ui,
|
|
3847
|
-
Fi,
|
|
3848
3847
|
$i,
|
|
3848
|
+
Fi,
|
|
3849
3849
|
Bi,
|
|
3850
3850
|
// building-block functions
|
|
3851
3851
|
Vi,
|
|
@@ -3853,9 +3853,9 @@ function Xi(...t) {
|
|
|
3853
3853
|
Wi,
|
|
3854
3854
|
Hi,
|
|
3855
3855
|
qi,
|
|
3856
|
-
gn,
|
|
3857
|
-
Ji,
|
|
3858
3856
|
vn,
|
|
3857
|
+
Ji,
|
|
3858
|
+
mn,
|
|
3859
3859
|
Yi,
|
|
3860
3860
|
Ge,
|
|
3861
3861
|
zi,
|
|
@@ -3863,14 +3863,14 @@ function Xi(...t) {
|
|
|
3863
3863
|
Qi,
|
|
3864
3864
|
void 0
|
|
3865
3865
|
].map((i, s) => t[s] || i);
|
|
3866
|
-
return
|
|
3866
|
+
return yn.set(e, Object.freeze(n)), e;
|
|
3867
3867
|
}
|
|
3868
|
-
const
|
|
3868
|
+
const bn = {};
|
|
3869
3869
|
let Zi = 0;
|
|
3870
3870
|
function He(t, e) {
|
|
3871
3871
|
const n = `atom${++Zi}`, i = {
|
|
3872
3872
|
toString() {
|
|
3873
|
-
return (
|
|
3873
|
+
return (bn ? "production" : void 0) !== "production" && this.debugLabel ? n + ":" + this.debugLabel : n;
|
|
3874
3874
|
}
|
|
3875
3875
|
};
|
|
3876
3876
|
return typeof t == "function" ? i.read = t : (i.init = t, i.read = es, i.write = ts), i;
|
|
@@ -3889,15 +3889,15 @@ function ns() {
|
|
|
3889
3889
|
}
|
|
3890
3890
|
let Ce;
|
|
3891
3891
|
function is() {
|
|
3892
|
-
return Ce || (Ce = ns(), (
|
|
3892
|
+
return Ce || (Ce = ns(), (bn ? "production" : void 0) !== "production" && (globalThis.__JOTAI_DEFAULT_STORE__ || (globalThis.__JOTAI_DEFAULT_STORE__ = Ce), globalThis.__JOTAI_DEFAULT_STORE__ !== Ce && console.warn(
|
|
3893
3893
|
"Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"
|
|
3894
3894
|
))), Ce;
|
|
3895
3895
|
}
|
|
3896
|
-
const ss = {}, os =
|
|
3896
|
+
const ss = {}, os = Wt(
|
|
3897
3897
|
void 0
|
|
3898
3898
|
);
|
|
3899
|
-
function
|
|
3900
|
-
return
|
|
3899
|
+
function _n(t) {
|
|
3900
|
+
return Gt(os) || is();
|
|
3901
3901
|
}
|
|
3902
3902
|
const lt = (t) => typeof t?.then == "function", ut = (t) => {
|
|
3903
3903
|
t.status || (t.status = "pending", t.then(
|
|
@@ -3915,7 +3915,7 @@ const lt = (t) => typeof t?.then == "function", ut = (t) => {
|
|
|
3915
3915
|
if (t.status === "fulfilled")
|
|
3916
3916
|
return t.value;
|
|
3917
3917
|
throw t.status === "rejected" ? t.reason : (ut(t), t);
|
|
3918
|
-
}), et = /* @__PURE__ */ new WeakMap(),
|
|
3918
|
+
}), et = /* @__PURE__ */ new WeakMap(), Vt = (t, e) => {
|
|
3919
3919
|
let n = et.get(t);
|
|
3920
3920
|
return n || (n = new Promise((i, s) => {
|
|
3921
3921
|
let r = t;
|
|
@@ -3935,7 +3935,7 @@ const lt = (t) => typeof t?.then == "function", ut = (t) => {
|
|
|
3935
3935
|
}), et.set(t, n)), n;
|
|
3936
3936
|
};
|
|
3937
3937
|
function qe(t, e) {
|
|
3938
|
-
const { delay: n, unstable_promiseStatus: i = !ht.use } = {}, s =
|
|
3938
|
+
const { delay: n, unstable_promiseStatus: i = !ht.use } = {}, s = _n(), [[r, o, d], l] = Tn(
|
|
3939
3939
|
(f) => {
|
|
3940
3940
|
const v = s.get(t);
|
|
3941
3941
|
return Object.is(f[0], v) && f[1] === s && f[2] === t ? f : [v, s, t];
|
|
@@ -3950,7 +3950,7 @@ function qe(t, e) {
|
|
|
3950
3950
|
try {
|
|
3951
3951
|
const v = s.get(t);
|
|
3952
3952
|
lt(v) && ut(
|
|
3953
|
-
|
|
3953
|
+
Vt(v, () => s.get(t))
|
|
3954
3954
|
);
|
|
3955
3955
|
} catch {
|
|
3956
3956
|
}
|
|
@@ -3961,15 +3961,15 @@ function qe(t, e) {
|
|
|
3961
3961
|
l();
|
|
3962
3962
|
});
|
|
3963
3963
|
return l(), f;
|
|
3964
|
-
}, [s, t, n, i]),
|
|
3965
|
-
const f =
|
|
3964
|
+
}, [s, t, n, i]), An(h), lt(h)) {
|
|
3965
|
+
const f = Vt(h, () => s.get(t));
|
|
3966
3966
|
return i && ut(f), rs(f);
|
|
3967
3967
|
}
|
|
3968
3968
|
return h;
|
|
3969
3969
|
}
|
|
3970
3970
|
function Je(t, e) {
|
|
3971
|
-
const n =
|
|
3972
|
-
return
|
|
3971
|
+
const n = _n();
|
|
3972
|
+
return Rn(
|
|
3973
3973
|
(...s) => {
|
|
3974
3974
|
if ((ss ? "production" : void 0) !== "production" && !("write" in t))
|
|
3975
3975
|
throw new Error("not writable atom");
|
|
@@ -3978,15 +3978,15 @@ function Je(t, e) {
|
|
|
3978
3978
|
[n, t]
|
|
3979
3979
|
);
|
|
3980
3980
|
}
|
|
3981
|
-
const
|
|
3981
|
+
const Sn = He([]);
|
|
3982
3982
|
function vs() {
|
|
3983
|
-
return qe(
|
|
3983
|
+
return qe(Sn);
|
|
3984
3984
|
}
|
|
3985
3985
|
function as() {
|
|
3986
|
-
return Je(
|
|
3986
|
+
return Je(Sn);
|
|
3987
3987
|
}
|
|
3988
3988
|
const Ye = () => {
|
|
3989
|
-
const t =
|
|
3989
|
+
const t = Gt(In);
|
|
3990
3990
|
if (!t)
|
|
3991
3991
|
throw new Error("useClient must be used within a TelnyxAIAgentProvider");
|
|
3992
3992
|
return t;
|
|
@@ -4000,12 +4000,12 @@ function cs() {
|
|
|
4000
4000
|
};
|
|
4001
4001
|
}, [t, e]), null;
|
|
4002
4002
|
}
|
|
4003
|
-
const
|
|
4003
|
+
const wn = He("connecting");
|
|
4004
4004
|
function ms() {
|
|
4005
|
-
return qe(
|
|
4005
|
+
return qe(wn);
|
|
4006
4006
|
}
|
|
4007
4007
|
function ds() {
|
|
4008
|
-
return Je(
|
|
4008
|
+
return Je(wn);
|
|
4009
4009
|
}
|
|
4010
4010
|
function ls() {
|
|
4011
4011
|
const t = Ye(), e = ds();
|
|
@@ -4016,12 +4016,12 @@ function ls() {
|
|
|
4016
4016
|
};
|
|
4017
4017
|
}, [t, e]), null;
|
|
4018
4018
|
}
|
|
4019
|
-
const
|
|
4019
|
+
const Cn = He(null);
|
|
4020
4020
|
function ys() {
|
|
4021
|
-
return qe(
|
|
4021
|
+
return qe(Cn);
|
|
4022
4022
|
}
|
|
4023
4023
|
function us() {
|
|
4024
|
-
return Je(
|
|
4024
|
+
return Je(Cn);
|
|
4025
4025
|
}
|
|
4026
4026
|
const hs = () => {
|
|
4027
4027
|
const t = Ye(), e = us();
|
|
@@ -4033,12 +4033,12 @@ const hs = () => {
|
|
|
4033
4033
|
t.removeListener("conversation.update", n);
|
|
4034
4034
|
};
|
|
4035
4035
|
}, [t, e]), null;
|
|
4036
|
-
},
|
|
4036
|
+
}, kn = He({ state: "listening" });
|
|
4037
4037
|
function bs() {
|
|
4038
|
-
return qe(
|
|
4038
|
+
return qe(kn);
|
|
4039
4039
|
}
|
|
4040
4040
|
function ps() {
|
|
4041
|
-
return Je(
|
|
4041
|
+
return Je(kn);
|
|
4042
4042
|
}
|
|
4043
4043
|
function fs() {
|
|
4044
4044
|
const t = Ye(), e = ps();
|
|
@@ -4051,24 +4051,24 @@ function fs() {
|
|
|
4051
4051
|
};
|
|
4052
4052
|
}, [t, e]), null;
|
|
4053
4053
|
}
|
|
4054
|
-
const
|
|
4054
|
+
const In = Wt(null), _s = ({
|
|
4055
4055
|
children: t,
|
|
4056
4056
|
agentId: e,
|
|
4057
4057
|
environment: n,
|
|
4058
4058
|
versionId: i,
|
|
4059
4059
|
debug: s
|
|
4060
4060
|
}) => {
|
|
4061
|
-
const [r, o] =
|
|
4061
|
+
const [r, o] = xn(() => new jt({ agentId: e, environment: n, versionId: i, debug: s }));
|
|
4062
4062
|
return pe(() => {
|
|
4063
4063
|
if (!r) {
|
|
4064
|
-
const d = new
|
|
4064
|
+
const d = new jt({ agentId: e, environment: n, versionId: i });
|
|
4065
4065
|
return o(d), () => {
|
|
4066
4066
|
d.disconnect();
|
|
4067
4067
|
};
|
|
4068
4068
|
}
|
|
4069
4069
|
}, [e, r, n, i]), pe(() => {
|
|
4070
4070
|
r?.connect();
|
|
4071
|
-
}, [r]), /* @__PURE__ */ we.jsxs(
|
|
4071
|
+
}, [r]), /* @__PURE__ */ we.jsxs(In.Provider, { value: r, children: [
|
|
4072
4072
|
/* @__PURE__ */ we.jsx(cs, {}),
|
|
4073
4073
|
/* @__PURE__ */ we.jsx(ls, {}),
|
|
4074
4074
|
/* @__PURE__ */ we.jsx(hs, {}),
|
|
@@ -4077,9 +4077,9 @@ const kn = Gt(null), _s = ({
|
|
|
4077
4077
|
] });
|
|
4078
4078
|
};
|
|
4079
4079
|
export {
|
|
4080
|
-
|
|
4080
|
+
In as ClientContext,
|
|
4081
4081
|
O as SwEvent,
|
|
4082
|
-
|
|
4082
|
+
jt as TelnyxAIAgent,
|
|
4083
4083
|
_s as TelnyxAIAgentProvider,
|
|
4084
4084
|
bs as useAgentState,
|
|
4085
4085
|
Ye as useClient,
|