@telnyx/ai-agent-lib 0.5.0-beta.0 → 0.5.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client-tools.d.ts +6 -0
- package/dist/index.js +431 -393
- package/dist/react/client-context.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13,21 +13,21 @@ function L(n, e, t, i) {
|
|
|
13
13
|
function r(c) {
|
|
14
14
|
try {
|
|
15
15
|
l(i.next(c));
|
|
16
|
-
} catch (
|
|
17
|
-
o(
|
|
16
|
+
} catch (f) {
|
|
17
|
+
o(f);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
function a(c) {
|
|
21
21
|
try {
|
|
22
22
|
l(i.throw(c));
|
|
23
|
-
} catch (
|
|
24
|
-
o(
|
|
23
|
+
} catch (f) {
|
|
24
|
+
o(f);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
function l(c) {
|
|
28
|
-
var
|
|
29
|
-
c.done ? s(c.value) : (
|
|
30
|
-
p(
|
|
28
|
+
var f;
|
|
29
|
+
c.done ? s(c.value) : (f = c.value, f instanceof t ? f : new t((function(p) {
|
|
30
|
+
p(f);
|
|
31
31
|
}))).then(r, a);
|
|
32
32
|
}
|
|
33
33
|
l((i = i.apply(n, [])).next());
|
|
@@ -118,7 +118,7 @@ var rs = Li((function(n) {
|
|
|
118
118
|
}
|
|
119
119
|
this.log = this.debug;
|
|
120
120
|
}
|
|
121
|
-
function
|
|
121
|
+
function f(g, I, k) {
|
|
122
122
|
return function() {
|
|
123
123
|
typeof console !== s && (c.call(this, I, k), this[g].apply(this, arguments));
|
|
124
124
|
};
|
|
@@ -126,7 +126,7 @@ var rs = Li((function(n) {
|
|
|
126
126
|
function p(g, I, k) {
|
|
127
127
|
return (function(A) {
|
|
128
128
|
return A === "debug" && (A = "log"), typeof console !== s && (A === "trace" && o ? l : console[A] !== void 0 ? a(console, A) : console.log !== void 0 ? a(console, "log") : i);
|
|
129
|
-
})(g) ||
|
|
129
|
+
})(g) || f.apply(this, arguments);
|
|
130
130
|
}
|
|
131
131
|
function b(g, I, k) {
|
|
132
132
|
var A, P = this;
|
|
@@ -152,14 +152,14 @@ var rs = Li((function(n) {
|
|
|
152
152
|
}, P.setLevel = function(N, d) {
|
|
153
153
|
if (typeof N == "string" && P.levels[N.toUpperCase()] !== void 0 && (N = P.levels[N.toUpperCase()]), !(typeof N == "number" && N >= 0 && N <= P.levels.SILENT)) throw "log.setLevel() called with invalid level: " + N;
|
|
154
154
|
if (A = N, d !== !1 && (function(u) {
|
|
155
|
-
var
|
|
155
|
+
var v = (r[u] || "silent").toUpperCase();
|
|
156
156
|
if (typeof window !== s && M) {
|
|
157
157
|
try {
|
|
158
|
-
return void (window.localStorage[M] =
|
|
158
|
+
return void (window.localStorage[M] = v);
|
|
159
159
|
} catch {
|
|
160
160
|
}
|
|
161
161
|
try {
|
|
162
|
-
window.document.cookie = encodeURIComponent(M) + "=" +
|
|
162
|
+
window.document.cookie = encodeURIComponent(M) + "=" + v + ";";
|
|
163
163
|
} catch {
|
|
164
164
|
}
|
|
165
165
|
}
|
|
@@ -439,14 +439,14 @@ class Ye {
|
|
|
439
439
|
var i;
|
|
440
440
|
const { request: s } = e, o = this.socketGeneration, r = s.method || "", a = new Promise(((l, c) => {
|
|
441
441
|
if (s.hasOwnProperty("result")) return l();
|
|
442
|
-
let
|
|
442
|
+
let f = !1, p = null;
|
|
443
443
|
const b = (m) => {
|
|
444
|
-
if (p !== null && (clearTimeout(p), this._pendingRequestTimers.delete(s.id), p = null), this._pendingRequestIds.delete(s.id), this._pendingRequestRejecters.delete(s.id),
|
|
444
|
+
if (p !== null && (clearTimeout(p), this._pendingRequestTimers.delete(s.id), p = null), this._pendingRequestIds.delete(s.id), this._pendingRequestRejecters.delete(s.id), f) return;
|
|
445
445
|
const { result: S, error: _ } = xi(m);
|
|
446
446
|
return _ ? c(_) : l(S);
|
|
447
447
|
};
|
|
448
448
|
$i(s.id, b), this._pendingRequestIds.add(s.id), this._pendingRequestRejecters.set(s.id, { reject: c, generation: o }), t && t > 0 && (p = setTimeout((() => {
|
|
449
|
-
if (
|
|
449
|
+
if (f = !0, p = null, this._pendingRequestTimers.delete(s.id), this._pendingRequestRejecters.delete(s.id), he(s.id, b), this._pendingRequestIds.delete(s.id), this.socketGeneration !== o) return h.debug(`Stale request timeout for ${s.id} (gen ${o}, current ${this.socketGeneration}) — settling with StaleRequestError`), void c(new yt(s.id, o, this.socketGeneration));
|
|
450
450
|
c(new ss(s.id, t, r));
|
|
451
451
|
}), t), this._pendingRequestTimers.set(s.id, p));
|
|
452
452
|
}));
|
|
@@ -1019,7 +1019,7 @@ const Ze = (n) => navigator.mediaDevices.getUserMedia(n), Me = (n) => n && n ins
|
|
|
1019
1019
|
if (h.error("getUserMedia error: ", i), ((s) => s.name === "NotReadableError" || s.name === "NotFoundError" || s.name === "OverconstrainedError")(i)) {
|
|
1020
1020
|
const s = ((o) => {
|
|
1021
1021
|
const { audio: r, video: a } = o;
|
|
1022
|
-
let l = !1, c = r,
|
|
1022
|
+
let l = !1, c = r, f = a;
|
|
1023
1023
|
if (typeof r == "object" && r !== null && "deviceId" in r) {
|
|
1024
1024
|
l = !0;
|
|
1025
1025
|
const p = Object.assign({}, r);
|
|
@@ -1028,9 +1028,9 @@ const Ze = (n) => navigator.mediaDevices.getUserMedia(n), Me = (n) => n && n ins
|
|
|
1028
1028
|
if (typeof a == "object" && a !== null && "deviceId" in a) {
|
|
1029
1029
|
l = !0;
|
|
1030
1030
|
const p = Object.assign({}, a);
|
|
1031
|
-
delete p.deviceId,
|
|
1031
|
+
delete p.deviceId, f = Object.keys(p).length === 0 || p;
|
|
1032
1032
|
}
|
|
1033
|
-
return l ? { audio: c, video:
|
|
1033
|
+
return l ? { audio: c, video: f } : null;
|
|
1034
1034
|
})(n);
|
|
1035
1035
|
if (s) {
|
|
1036
1036
|
h.warn("Device not found or not readable, falling back to default device");
|
|
@@ -1117,19 +1117,19 @@ function Os() {
|
|
|
1117
1117
|
const { browserInfo: n, name: e, version: t, supportAudio: i, supportVideo: s } = (function() {
|
|
1118
1118
|
if (!window || !window.navigator || !window.navigator.userAgent) throw new Error("You should use @telnyx/webrtc in a web browser such as Chrome|Firefox|Safari");
|
|
1119
1119
|
if (navigator.userAgent.match(/chrom(e|ium)/gim) && !navigator.userAgent.match(/OPR\/[0-9]{2}/gi) && !navigator.userAgent.match(/edg/gim)) {
|
|
1120
|
-
const
|
|
1120
|
+
const f = navigator.userAgent.match(/chrom(e|ium)\/[0-9]+\./gim)[0].split("/"), p = f[0], b = parseInt(f[1], 10);
|
|
1121
1121
|
return { browserInfo: navigator.userAgent, name: p, version: b, supportAudio: !0, supportVideo: !0 };
|
|
1122
1122
|
}
|
|
1123
1123
|
if (navigator.userAgent.match(/firefox/gim) && !navigator.userAgent.match(/OPR\/[0-9]{2}/gi) && !navigator.userAgent.match(/edg/gim)) {
|
|
1124
|
-
const
|
|
1124
|
+
const f = navigator.userAgent.match(/firefox\/[0-9]+\./gim)[0].split("/"), p = f[0], b = parseInt(f[1], 10);
|
|
1125
1125
|
return { browserInfo: navigator.userAgent, name: p, version: b, supportAudio: !0, supportVideo: !1 };
|
|
1126
1126
|
}
|
|
1127
1127
|
if (navigator.userAgent.match(/safari/gim) && !navigator.userAgent.match(/OPR\/[0-9]{2}/gi) && !navigator.userAgent.match(/edg/gim)) {
|
|
1128
|
-
const
|
|
1129
|
-
return { browserInfo: navigator.userAgent, name:
|
|
1128
|
+
const f = navigator.userAgent.match(/safari/gim)[0], p = navigator.userAgent.match(/version\/[0-9]+\./gim)[0].split("/"), b = parseInt(p[1], 10);
|
|
1129
|
+
return { browserInfo: navigator.userAgent, name: f, version: b, supportAudio: !0, supportVideo: !0 };
|
|
1130
1130
|
}
|
|
1131
1131
|
if (navigator.userAgent.match(/edg/gim) && !navigator.userAgent.match(/OPR\/[0-9]{2}/gi)) {
|
|
1132
|
-
const
|
|
1132
|
+
const f = navigator.userAgent.match(/edg\/[0-9]+\./gim)[0].split("/"), p = f[0], b = parseInt(f[1], 10);
|
|
1133
1133
|
return { browserInfo: navigator.userAgent, name: p, version: b, supportAudio: !0, supportVideo: !0 };
|
|
1134
1134
|
}
|
|
1135
1135
|
throw new Error("This browser does not support @telnyx/webrtc. To see browser support list: `TelnyxRTC.webRTCSupportedBrowserList()`");
|
|
@@ -1223,7 +1223,7 @@ class B {
|
|
|
1223
1223
|
const a = (o = this.logCollector) === null || o === void 0 ? void 0 : o.getLogs(), l = a && a.length > 0;
|
|
1224
1224
|
if (!this.options.enabled) return void h.info("CallReportCollector: Skipping report — call reports disabled");
|
|
1225
1225
|
if (this.statsBuffer.length === 0 && !l) return void h.info("CallReportCollector: Skipping report — no stats or logs collected");
|
|
1226
|
-
const c = this._segmentIndex > 0,
|
|
1226
|
+
const c = this._segmentIndex > 0, f = this._segmentIndex, p = Object.assign(Object.assign({ summary: Object.assign(Object.assign({}, e), { durationSeconds: this.callEndTime && this.callStartTime ? (this.callEndTime.getTime() - this.callStartTime.getTime()) / 1e3 : void 0, startTimestamp: this.callStartTime.toISOString(), endTimestamp: (r = this.callEndTime) === null || r === void 0 ? void 0 : r.toISOString() }), stats: this.statsBuffer }, a && a.length > 0 ? { logs: a } : {}), c ? { segment: f } : {});
|
|
1227
1227
|
yield this._sendPayload(p, t, i, s, !0);
|
|
1228
1228
|
}));
|
|
1229
1229
|
}
|
|
@@ -1235,8 +1235,8 @@ class B {
|
|
|
1235
1235
|
_sendPayload(e, t, i, s, o = !0) {
|
|
1236
1236
|
var r, a;
|
|
1237
1237
|
return L(this, void 0, void 0, (function* () {
|
|
1238
|
-
const l = new URL(i), c = `${l.protocol.replace(/^ws/, "http")}//${l.host}/call_report`,
|
|
1239
|
-
h.info(`CallReportCollector: Posting ${
|
|
1238
|
+
const l = new URL(i), c = `${l.protocol.replace(/^ws/, "http")}//${l.host}/call_report`, f = o ? "final report" : `intermediate segment ${e.segment}`;
|
|
1239
|
+
h.info(`CallReportCollector: Posting ${f}`, { endpoint: c, intervals: e.stats.length, logEntries: (a = (r = e.logs) === null || r === void 0 ? void 0 : r.length) !== null && a !== void 0 ? a : 0, callId: e.summary.callId, segment: e.segment });
|
|
1240
1240
|
const p = { "Content-Type": "application/json", "x-call-report-id": t, "x-call-id": e.summary.callId };
|
|
1241
1241
|
s && (p["x-voice-sdk-id"] = s);
|
|
1242
1242
|
const b = JSON.stringify(e), m = o && b.length <= B.KEEPALIVE_BODY_LIMIT_BYTES;
|
|
@@ -1244,30 +1244,30 @@ class B {
|
|
|
1244
1244
|
for (let _ = 0; _ <= B.RETRY_DELAYS_MS.length; _++) {
|
|
1245
1245
|
try {
|
|
1246
1246
|
const I = yield fetch(c, Object.assign({ method: "POST", headers: p, body: b }, m ? { keepalive: !0 } : {}));
|
|
1247
|
-
if (I.ok) return void h.info(`CallReportCollector: Successfully posted ${
|
|
1247
|
+
if (I.ok) return void h.info(`CallReportCollector: Successfully posted ${f}`, { attempt: _ + 1, status: I.status });
|
|
1248
1248
|
{
|
|
1249
1249
|
const k = yield I.text();
|
|
1250
|
-
S = new Error(`Call report POST failed with status ${I.status}`), h.error(`CallReportCollector: Failed to post ${
|
|
1250
|
+
S = new Error(`Call report POST failed with status ${I.status}`), h.error(`CallReportCollector: Failed to post ${f}`, { attempt: _ + 1, status: I.status, error: k });
|
|
1251
1251
|
}
|
|
1252
1252
|
} catch (I) {
|
|
1253
|
-
S = I, h.warn(`CallReportCollector: Network error posting ${
|
|
1253
|
+
S = I, h.warn(`CallReportCollector: Network error posting ${f}`, { attempt: _ + 1, error: I });
|
|
1254
1254
|
}
|
|
1255
1255
|
const g = B.RETRY_DELAYS_MS[_];
|
|
1256
1256
|
if (g === void 0) break;
|
|
1257
|
-
h.info(`CallReportCollector: Retrying ${
|
|
1257
|
+
h.info(`CallReportCollector: Retrying ${f} in ${g}ms`, { attempt: _ + 2 }), yield new Promise(((I) => setTimeout(I, g)));
|
|
1258
1258
|
}
|
|
1259
|
-
throw h.error(`CallReportCollector: Exhausted retries posting ${
|
|
1259
|
+
throw h.error(`CallReportCollector: Exhausted retries posting ${f}`, { error: S }), S instanceof Error ? S : new Error("Call report POST failed after retries");
|
|
1260
1260
|
}));
|
|
1261
1261
|
}
|
|
1262
1262
|
getStatsBuffer() {
|
|
1263
1263
|
return this.statsBuffer;
|
|
1264
1264
|
}
|
|
1265
1265
|
shouldForceRelayCandidateForRecovery() {
|
|
1266
|
-
var e, t, i, s, o, r, a, l, c,
|
|
1266
|
+
var e, t, i, s, o, r, a, l, c, f, p, b, m, S, _, g;
|
|
1267
1267
|
if (this.statsBuffer.length < 2) return !1;
|
|
1268
1268
|
const I = this.statsBuffer[this.statsBuffer.length - 1], k = this.statsBuffer[this.statsBuffer.length - 2], A = (e = I.ice) === null || e === void 0 ? void 0 : e.local;
|
|
1269
1269
|
if (!(A?.networkType === "vpn" && A?.candidateType !== "relay")) return !1;
|
|
1270
|
-
const P = ((t = I.ice) === null || t === void 0 ? void 0 : t.writable) === !1, M = ((i = I.transport) === null || i === void 0 ? void 0 : i.iceState) === "disconnected" || ((s = I.transport) === null || s === void 0 ? void 0 : s.iceState) === "failed", Y = this._positiveDelta((o = I.ice) === null || o === void 0 ? void 0 : o.requestsSent, (r = k.ice) === null || r === void 0 ? void 0 : r.requestsSent), H = this._positiveDelta((a = I.ice) === null || a === void 0 ? void 0 : a.responsesReceived, (l = k.ice) === null || l === void 0 ? void 0 : l.responsesReceived), N = Y > 0 && H === 0, d = this._positiveDelta((
|
|
1270
|
+
const P = ((t = I.ice) === null || t === void 0 ? void 0 : t.writable) === !1, M = ((i = I.transport) === null || i === void 0 ? void 0 : i.iceState) === "disconnected" || ((s = I.transport) === null || s === void 0 ? void 0 : s.iceState) === "failed", Y = this._positiveDelta((o = I.ice) === null || o === void 0 ? void 0 : o.requestsSent, (r = k.ice) === null || r === void 0 ? void 0 : r.requestsSent), H = this._positiveDelta((a = I.ice) === null || a === void 0 ? void 0 : a.responsesReceived, (l = k.ice) === null || l === void 0 ? void 0 : l.responsesReceived), N = Y > 0 && H === 0, d = this._positiveDelta((f = (c = I.audio) === null || c === void 0 ? void 0 : c.outbound) === null || f === void 0 ? void 0 : f.bytesSent, (b = (p = k.audio) === null || p === void 0 ? void 0 : p.outbound) === null || b === void 0 ? void 0 : b.bytesSent), u = this._positiveDelta((S = (m = I.audio) === null || m === void 0 ? void 0 : m.inbound) === null || S === void 0 ? void 0 : S.bytesReceived, (g = (_ = k.audio) === null || _ === void 0 ? void 0 : _.inbound) === null || g === void 0 ? void 0 : g.bytesReceived);
|
|
1271
1271
|
return P || M || N || d > 0 && u === 0;
|
|
1272
1272
|
}
|
|
1273
1273
|
getLogs() {
|
|
@@ -1300,14 +1300,14 @@ class B {
|
|
|
1300
1300
|
return L(this, void 0, void 0, (function* () {
|
|
1301
1301
|
if (this.peerConnection && this.intervalStartTime) try {
|
|
1302
1302
|
const t = yield this.peerConnection.getStats(), i = /* @__PURE__ */ new Date();
|
|
1303
|
-
let s, o, r, a, l, c = null,
|
|
1303
|
+
let s, o, r, a, l, c = null, f = null, p = null, b = null;
|
|
1304
1304
|
if (t.forEach(((_) => {
|
|
1305
1305
|
switch (_.type) {
|
|
1306
1306
|
case "outbound-rtp":
|
|
1307
1307
|
_.kind === "audio" && _.mediaType === "audio" && (c = _);
|
|
1308
1308
|
break;
|
|
1309
1309
|
case "inbound-rtp":
|
|
1310
|
-
_.kind === "audio" && _.mediaType === "audio" && (
|
|
1310
|
+
_.kind === "audio" && _.mediaType === "audio" && (f = _);
|
|
1311
1311
|
break;
|
|
1312
1312
|
case "candidate-pair":
|
|
1313
1313
|
(_.nominated || _.state === "succeeded") && (p = _);
|
|
@@ -1326,22 +1326,22 @@ class B {
|
|
|
1326
1326
|
}
|
|
1327
1327
|
this.previousStats.outboundBytes = c.bytesSent;
|
|
1328
1328
|
}
|
|
1329
|
-
if (
|
|
1330
|
-
const _ = this._getInboundAudioLevel(t,
|
|
1331
|
-
if (_ !== null && this.intervalAudioLevels.inbound.push(_),
|
|
1332
|
-
const g = (
|
|
1329
|
+
if (f) {
|
|
1330
|
+
const _ = this._getInboundAudioLevel(t, f);
|
|
1331
|
+
if (_ !== null && this.intervalAudioLevels.inbound.push(_), f.jitter !== void 0 && this.intervalJitters.push(1e3 * f.jitter), this.previousStats.inboundBytes !== void 0 && this.previousStats.timestamp !== void 0) {
|
|
1332
|
+
const g = (f.bytesReceived || 0) - this.previousStats.inboundBytes, I = (f.timestamp || i.getTime()) - this.previousStats.timestamp;
|
|
1333
1333
|
if (I > 0) {
|
|
1334
1334
|
const k = 8 * g * 1e3 / I;
|
|
1335
1335
|
this.intervalBitrates.inbound.push(k);
|
|
1336
1336
|
}
|
|
1337
1337
|
}
|
|
1338
|
-
this.previousStats.inboundBytes =
|
|
1338
|
+
this.previousStats.inboundBytes = f.bytesReceived;
|
|
1339
1339
|
}
|
|
1340
1340
|
p && p.currentRoundTripTime !== void 0 && this.intervalRTTs.push(p.currentRoundTripTime), p && (s = this._resolveCandidate(t, p.localCandidateId), o = this._resolveCandidate(t, p.remoteCandidateId)), p && (r = Object.assign(Object.assign({ id: p.id, state: p.state, nominated: p.nominated, writable: p.writable, requestsSent: p.requestsSent, responsesReceived: p.responsesReceived }, s ? { local: s } : {}), o ? { remote: o } : {}), this.previousCandidatePairSnapshot !== null && p.id !== this.previousCandidatePairSnapshot.id && (h.debug("CallReportCollector: ICE candidate pair changed mid-call", { previous: this.previousCandidatePairSnapshot, current: r }), this._emitWarning(Gn)), this.previousCandidatePairSnapshot = r), c && (a = this._getLocalAudioTrackSnapshot(), l = this._getOutboundAudioSourceStats(t, c)), this._logLocalAudioTrackSnapshot(a, l), this.previousStats.timestamp = i.getTime();
|
|
1341
1341
|
const m = i.getTime() - this.intervalStartTime.getTime(), S = this._collectionIntervalFor(this.intervalStartTime);
|
|
1342
1342
|
if (e || m >= S) {
|
|
1343
|
-
const _ = this._createStatsEntry(this.intervalStartTime, i, c,
|
|
1344
|
-
this.statsBuffer.push(_), this.statsBuffer.length > this.MAX_BUFFER_SIZE && (this.statsBuffer.shift(), h.warn("CallReportCollector: Buffer size limit reached, removing oldest entry")), this._checkQualityWarnings(_,
|
|
1343
|
+
const _ = this._createStatsEntry(this.intervalStartTime, i, c, f, p, s, o, b, a, l);
|
|
1344
|
+
this.statsBuffer.push(_), this.statsBuffer.length > this.MAX_BUFFER_SIZE && (this.statsBuffer.shift(), h.warn("CallReportCollector: Buffer size limit reached, removing oldest entry")), this._checkQualityWarnings(_, f), this._requestIntermediateFlushIfNeeded(i), this.intervalStartTime = i, this._resetIntervalAccumulators();
|
|
1345
1345
|
}
|
|
1346
1346
|
} catch (t) {
|
|
1347
1347
|
h.error("CallReportCollector: Error collecting stats", { error: t });
|
|
@@ -1367,7 +1367,7 @@ class B {
|
|
|
1367
1367
|
}
|
|
1368
1368
|
}
|
|
1369
1369
|
_checkQualityWarnings(e, t) {
|
|
1370
|
-
var i, s, o, r, a, l, c,
|
|
1370
|
+
var i, s, o, r, a, l, c, f, p, b, m, S, _, g, I;
|
|
1371
1371
|
if (!this.onWarning) return;
|
|
1372
1372
|
const k = (i = e.connection) === null || i === void 0 ? void 0 : i.roundTripTimeAvg, A = (o = (s = e.audio) === null || s === void 0 ? void 0 : s.inbound) === null || o === void 0 ? void 0 : o.jitterAvg;
|
|
1373
1373
|
let P;
|
|
@@ -1384,7 +1384,7 @@ class B {
|
|
|
1384
1384
|
this._trackBreach(jt, Y < B.THRESHOLD_MOS);
|
|
1385
1385
|
} else this._trackBreach(jt, !1);
|
|
1386
1386
|
if (((c = (l = e.audio) === null || l === void 0 ? void 0 : l.inbound) === null || c === void 0 ? void 0 : c.bytesReceived) !== void 0) {
|
|
1387
|
-
const M = (b = (p = (
|
|
1387
|
+
const M = (b = (p = (f = this._previousStatsEntryForWarnings) === null || f === void 0 ? void 0 : f.audio) === null || p === void 0 ? void 0 : p.inbound) === null || b === void 0 ? void 0 : b.bytesReceived, Y = e.audio.inbound.bytesReceived;
|
|
1388
1388
|
this._trackBreach(ki, M !== void 0 && Y - M == 0);
|
|
1389
1389
|
}
|
|
1390
1390
|
if (((S = (m = e.audio) === null || m === void 0 ? void 0 : m.outbound) === null || S === void 0 ? void 0 : S.bytesSent) !== void 0) {
|
|
@@ -1429,9 +1429,9 @@ class B {
|
|
|
1429
1429
|
h.error(`CallReportCollector: Failed to emit warning ${e}`, { error: i });
|
|
1430
1430
|
}
|
|
1431
1431
|
}
|
|
1432
|
-
_createStatsEntry(e, t, i, s, o, r, a, l, c,
|
|
1432
|
+
_createStatsEntry(e, t, i, s, o, r, a, l, c, f) {
|
|
1433
1433
|
const p = { intervalStartUtc: e.toISOString(), intervalEndUtc: t.toISOString(), audio: {} };
|
|
1434
|
-
return i && (p.audio.outbound = Object.assign(Object.assign({ packetsSent: i.packetsSent, bytesSent: i.bytesSent, audioLevelAvg: this._average(this.intervalAudioLevels.outbound), bitrateAvg: this._average(this.intervalBitrates.outbound) }, c ? { localTrack: c } : {}),
|
|
1434
|
+
return i && (p.audio.outbound = Object.assign(Object.assign({ packetsSent: i.packetsSent, bytesSent: i.bytesSent, audioLevelAvg: this._average(this.intervalAudioLevels.outbound), bitrateAvg: this._average(this.intervalBitrates.outbound) }, c ? { localTrack: c } : {}), f ? { mediaSource: f } : {})), s && (p.audio.inbound = { packetsReceived: s.packetsReceived, bytesReceived: s.bytesReceived, packetsLost: s.packetsLost, packetsDiscarded: s.packetsDiscarded, jitterBufferDelay: s.jitterBufferDelay, jitterBufferEmittedCount: s.jitterBufferEmittedCount, totalSamplesReceived: s.totalSamplesReceived, concealedSamples: s.concealedSamples, concealmentEvents: s.concealmentEvents, audioLevelAvg: this._average(this.intervalAudioLevels.inbound), jitterAvg: this._average(this.intervalJitters), bitrateAvg: this._average(this.intervalBitrates.inbound) }), o && (p.connection = { roundTripTimeAvg: this._average(this.intervalRTTs), packetsSent: o.packetsSent, packetsReceived: o.packetsReceived, bytesSent: o.bytesSent, bytesReceived: o.bytesReceived }, p.ice = Object.assign(Object.assign({ id: o.id, state: o.state, nominated: o.nominated, writable: o.writable, requestsSent: o.requestsSent, responsesReceived: o.responsesReceived }, r ? { local: r } : {}), a ? { remote: a } : {})), l && (p.transport = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, l.iceState !== void 0 ? { iceState: l.iceState } : {}), l.dtlsState !== void 0 ? { dtlsState: l.dtlsState } : {}), l.srtpCipher !== void 0 ? { srtpCipher: l.srtpCipher } : {}), l.tlsVersion !== void 0 ? { tlsVersion: l.tlsVersion } : {}), l.selectedCandidatePairChanges !== void 0 ? { selectedCandidatePairChanges: l.selectedCandidatePairChanges } : {})), p;
|
|
1435
1435
|
}
|
|
1436
1436
|
_resolveCandidate(e, t) {
|
|
1437
1437
|
if (!t) return void h.debug("CallReportCollector: candidateId is empty, skipping resolve");
|
|
@@ -1504,8 +1504,8 @@ class B {
|
|
|
1504
1504
|
if (this.previousStats[s] = e, this.previousStats[o] = t, r === void 0 || a === void 0) return null;
|
|
1505
1505
|
const l = e - r, c = t - a;
|
|
1506
1506
|
if (c <= 0) return null;
|
|
1507
|
-
const
|
|
1508
|
-
return Math.min(1, Math.max(0,
|
|
1507
|
+
const f = Math.sqrt(l / c);
|
|
1508
|
+
return Math.min(1, Math.max(0, f));
|
|
1509
1509
|
}
|
|
1510
1510
|
_getTrackAudioLevel(e, t) {
|
|
1511
1511
|
var i;
|
|
@@ -1580,39 +1580,39 @@ var Ge, Bi = Li((function(n, e) {
|
|
|
1580
1580
|
function o(d) {
|
|
1581
1581
|
return d._maxListeners === void 0 ? s.defaultMaxListeners : d._maxListeners;
|
|
1582
1582
|
}
|
|
1583
|
-
function r(d, u,
|
|
1583
|
+
function r(d, u, v, y) {
|
|
1584
1584
|
var C, R, T;
|
|
1585
|
-
if (typeof
|
|
1586
|
-
if ((R = d._events) ? (R.newListener && (d.emit("newListener", u,
|
|
1587
|
-
if (typeof T == "function" ? T = R[u] = y ? [
|
|
1585
|
+
if (typeof v != "function") throw new TypeError('"listener" argument must be a function');
|
|
1586
|
+
if ((R = d._events) ? (R.newListener && (d.emit("newListener", u, v.listener ? v.listener : v), R = d._events), T = R[u]) : (R = d._events = new i(), d._eventsCount = 0), T) {
|
|
1587
|
+
if (typeof T == "function" ? T = R[u] = y ? [v, T] : [T, v] : y ? T.unshift(v) : T.push(v), !T.warned && (C = o(d)) && 0 < C && T.length > C) {
|
|
1588
1588
|
T.warned = !0;
|
|
1589
1589
|
var D = new Error("Possible EventEmitter memory leak detected. " + T.length + " " + u + " listeners added. Use emitter.setMaxListeners() to increase limit");
|
|
1590
1590
|
D.name = "MaxListenersExceededWarning", D.emitter = d, D.type = u, D.count = T.length, (function(F) {
|
|
1591
1591
|
typeof console.warn == "function" ? console.warn(F) : console.log(F);
|
|
1592
1592
|
})(D);
|
|
1593
1593
|
}
|
|
1594
|
-
} else T = R[u] =
|
|
1594
|
+
} else T = R[u] = v, ++d._eventsCount;
|
|
1595
1595
|
return d;
|
|
1596
1596
|
}
|
|
1597
|
-
function a(d, u,
|
|
1597
|
+
function a(d, u, v) {
|
|
1598
1598
|
function y() {
|
|
1599
|
-
d.removeListener(u, y), C || (C = !0,
|
|
1599
|
+
d.removeListener(u, y), C || (C = !0, v.apply(d, arguments));
|
|
1600
1600
|
}
|
|
1601
1601
|
var C = !1;
|
|
1602
|
-
return y.listener =
|
|
1602
|
+
return y.listener = v, y;
|
|
1603
1603
|
}
|
|
1604
1604
|
function l(d) {
|
|
1605
1605
|
var u = this._events;
|
|
1606
1606
|
if (u) {
|
|
1607
|
-
var
|
|
1608
|
-
if (typeof
|
|
1609
|
-
if (
|
|
1607
|
+
var v = u[d];
|
|
1608
|
+
if (typeof v == "function") return 1;
|
|
1609
|
+
if (v) return v.length;
|
|
1610
1610
|
}
|
|
1611
1611
|
return 0;
|
|
1612
1612
|
}
|
|
1613
1613
|
function c(d, u) {
|
|
1614
|
-
for (var
|
|
1615
|
-
return
|
|
1614
|
+
for (var v = Array(u); u--; ) v[u] = d[u];
|
|
1615
|
+
return v;
|
|
1616
1616
|
}
|
|
1617
1617
|
Object.defineProperty(e, "__esModule", { value: !0 }), i.prototype = /* @__PURE__ */ Object.create(null), s.EventEmitter = s, s.usingDomains = !1, s.prototype.domain = void 0, s.prototype._events = void 0, s.prototype._maxListeners = void 0, s.defaultMaxListeners = 10, s.init = function() {
|
|
1618
1618
|
this.domain = null, s.usingDomains && t.active && !(this instanceof t.Domain) && (this.domain = t.active), this._events && this._events !== Object.getPrototypeOf(this)._events || (this._events = new i(), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
|
|
@@ -1622,7 +1622,7 @@ var Ge, Bi = Li((function(n, e) {
|
|
|
1622
1622
|
}, s.prototype.getMaxListeners = function() {
|
|
1623
1623
|
return o(this);
|
|
1624
1624
|
}, s.prototype.emit = function(d) {
|
|
1625
|
-
var u,
|
|
1625
|
+
var u, v, y, C, R, T, D, F = d === "error";
|
|
1626
1626
|
if (T = this._events) F = F && T.error == null;
|
|
1627
1627
|
else if (!F) return !1;
|
|
1628
1628
|
if (D = this.domain, F) {
|
|
@@ -1633,39 +1633,39 @@ var Ge, Bi = Li((function(n, e) {
|
|
|
1633
1633
|
}
|
|
1634
1634
|
return u || (u = new Error('Uncaught, unspecified "error" event')), u.domainEmitter = this, u.domain = D, u.domainThrown = !1, D.emit("error", u), !1;
|
|
1635
1635
|
}
|
|
1636
|
-
if (!(
|
|
1637
|
-
var z = typeof
|
|
1636
|
+
if (!(v = T[d])) return !1;
|
|
1637
|
+
var z = typeof v == "function";
|
|
1638
1638
|
switch (y = arguments.length) {
|
|
1639
1639
|
case 1:
|
|
1640
1640
|
(function(q, E, U) {
|
|
1641
1641
|
if (E) q.call(U);
|
|
1642
1642
|
else for (var $ = q.length, V = c(q, $), Z = 0; Z < $; ++Z) V[Z].call(U);
|
|
1643
|
-
})(
|
|
1643
|
+
})(v, z, this);
|
|
1644
1644
|
break;
|
|
1645
1645
|
case 2:
|
|
1646
1646
|
(function(q, E, U, $) {
|
|
1647
1647
|
if (E) q.call(U, $);
|
|
1648
1648
|
else for (var V = q.length, Z = c(q, V), ie = 0; ie < V; ++ie) Z[ie].call(U, $);
|
|
1649
|
-
})(
|
|
1649
|
+
})(v, z, this, arguments[1]);
|
|
1650
1650
|
break;
|
|
1651
1651
|
case 3:
|
|
1652
1652
|
(function(q, E, U, $, V) {
|
|
1653
1653
|
if (E) q.call(U, $, V);
|
|
1654
|
-
else for (var Z = q.length, ie = c(q, Z),
|
|
1655
|
-
})(
|
|
1654
|
+
else for (var Z = q.length, ie = c(q, Z), J = 0; J < Z; ++J) ie[J].call(U, $, V);
|
|
1655
|
+
})(v, z, this, arguments[1], arguments[2]);
|
|
1656
1656
|
break;
|
|
1657
1657
|
case 4:
|
|
1658
1658
|
(function(q, E, U, $, V, Z) {
|
|
1659
1659
|
if (E) q.call(U, $, V, Z);
|
|
1660
|
-
else for (var ie = q.length,
|
|
1661
|
-
})(
|
|
1660
|
+
else for (var ie = q.length, J = c(q, ie), de = 0; de < ie; ++de) J[de].call(U, $, V, Z);
|
|
1661
|
+
})(v, z, this, arguments[1], arguments[2], arguments[3]);
|
|
1662
1662
|
break;
|
|
1663
1663
|
default:
|
|
1664
1664
|
for (C = Array(y - 1), R = 1; R < y; R++) C[R - 1] = arguments[R];
|
|
1665
1665
|
(function(q, E, U, $) {
|
|
1666
1666
|
if (E) q.apply(U, $);
|
|
1667
1667
|
else for (var V = q.length, Z = c(q, V), ie = 0; ie < V; ++ie) Z[ie].apply(U, $);
|
|
1668
|
-
})(
|
|
1668
|
+
})(v, z, this, C);
|
|
1669
1669
|
}
|
|
1670
1670
|
return !0;
|
|
1671
1671
|
}, s.prototype.addListener = function(d, u) {
|
|
@@ -1679,98 +1679,98 @@ var Ge, Bi = Li((function(n, e) {
|
|
|
1679
1679
|
if (typeof u != "function") throw new TypeError('"listener" argument must be a function');
|
|
1680
1680
|
return this.prependListener(d, a(this, d, u)), this;
|
|
1681
1681
|
}, s.prototype.removeListener = function(d, u) {
|
|
1682
|
-
var
|
|
1682
|
+
var v, y, C, R, T;
|
|
1683
1683
|
if (typeof u != "function") throw new TypeError('"listener" argument must be a function');
|
|
1684
1684
|
if (!(y = this._events)) return this;
|
|
1685
|
-
if (!(
|
|
1686
|
-
if (
|
|
1687
|
-
else if (typeof
|
|
1688
|
-
for (C = -1, R =
|
|
1689
|
-
T =
|
|
1685
|
+
if (!(v = y[d])) return this;
|
|
1686
|
+
if (v === u || v.listener && v.listener === u) --this._eventsCount == 0 ? this._events = new i() : (delete y[d], y.removeListener && this.emit("removeListener", d, v.listener || u));
|
|
1687
|
+
else if (typeof v != "function") {
|
|
1688
|
+
for (C = -1, R = v.length; 0 < R--; ) if (v[R] === u || v[R].listener && v[R].listener === u) {
|
|
1689
|
+
T = v[R].listener, C = R;
|
|
1690
1690
|
break;
|
|
1691
1691
|
}
|
|
1692
1692
|
if (0 > C) return this;
|
|
1693
|
-
if (
|
|
1694
|
-
if (
|
|
1693
|
+
if (v.length === 1) {
|
|
1694
|
+
if (v[0] = void 0, --this._eventsCount == 0) return this._events = new i(), this;
|
|
1695
1695
|
delete y[d];
|
|
1696
1696
|
} else (function(D, F) {
|
|
1697
1697
|
for (var X = F, z = X + 1, q = D.length; z < q; X += 1, z += 1) D[X] = D[z];
|
|
1698
1698
|
D.pop();
|
|
1699
|
-
})(
|
|
1699
|
+
})(v, C);
|
|
1700
1700
|
y.removeListener && this.emit("removeListener", d, T || u);
|
|
1701
1701
|
}
|
|
1702
1702
|
return this;
|
|
1703
1703
|
}, s.prototype.removeAllListeners = function(d) {
|
|
1704
|
-
var u,
|
|
1705
|
-
if (!(
|
|
1706
|
-
if (!
|
|
1704
|
+
var u, v;
|
|
1705
|
+
if (!(v = this._events)) return this;
|
|
1706
|
+
if (!v.removeListener) return arguments.length === 0 ? (this._events = new i(), this._eventsCount = 0) : v[d] && (--this._eventsCount == 0 ? this._events = new i() : delete v[d]), this;
|
|
1707
1707
|
if (arguments.length === 0) {
|
|
1708
|
-
for (var y, C = Object.keys(
|
|
1708
|
+
for (var y, C = Object.keys(v), R = 0; R < C.length; ++R) (y = C[R]) !== "removeListener" && this.removeAllListeners(y);
|
|
1709
1709
|
return this.removeAllListeners("removeListener"), this._events = new i(), this._eventsCount = 0, this;
|
|
1710
1710
|
}
|
|
1711
|
-
if (typeof (u =
|
|
1711
|
+
if (typeof (u = v[d]) == "function") this.removeListener(d, u);
|
|
1712
1712
|
else if (u) do
|
|
1713
1713
|
this.removeListener(d, u[u.length - 1]);
|
|
1714
1714
|
while (u[0]);
|
|
1715
1715
|
return this;
|
|
1716
1716
|
}, s.prototype.listeners = function(d) {
|
|
1717
|
-
var u,
|
|
1718
|
-
return y ?
|
|
1717
|
+
var u, v, y = this._events;
|
|
1718
|
+
return y ? v = (u = y[d]) ? typeof u == "function" ? [u.listener || u] : (function(C) {
|
|
1719
1719
|
for (var R = Array(C.length), T = 0; T < R.length; ++T) R[T] = C[T].listener || C[T];
|
|
1720
1720
|
return R;
|
|
1721
|
-
})(u) : [] :
|
|
1721
|
+
})(u) : [] : v = [], v;
|
|
1722
1722
|
}, s.listenerCount = function(d, u) {
|
|
1723
1723
|
return typeof d.listenerCount == "function" ? d.listenerCount(u) : l.call(d, u);
|
|
1724
1724
|
}, s.prototype.listenerCount = l, s.prototype.eventNames = function() {
|
|
1725
1725
|
return 0 < this._eventsCount ? Reflect.ownKeys(this._events) : [];
|
|
1726
1726
|
};
|
|
1727
|
-
var
|
|
1727
|
+
var f, p = new Uint8Array(16);
|
|
1728
1728
|
function b() {
|
|
1729
|
-
if (!
|
|
1730
|
-
return
|
|
1729
|
+
if (!f && !(f = 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");
|
|
1730
|
+
return f(p);
|
|
1731
1731
|
}
|
|
1732
1732
|
for (var m = /^(?:[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, S = [], _ = 0; 256 > _; ++_) S.push((_ + 256).toString(16).substr(1));
|
|
1733
1733
|
function g(d) {
|
|
1734
|
-
var u = 1 < arguments.length && arguments[1] !== void 0 ? arguments[1] : 0,
|
|
1734
|
+
var u = 1 < arguments.length && arguments[1] !== void 0 ? arguments[1] : 0, v = (S[d[u + 0]] + S[d[u + 1]] + S[d[u + 2]] + S[d[u + 3]] + "-" + S[d[u + 4]] + S[d[u + 5]] + "-" + S[d[u + 6]] + S[d[u + 7]] + "-" + S[d[u + 8]] + S[d[u + 9]] + "-" + S[d[u + 10]] + S[d[u + 11]] + S[d[u + 12]] + S[d[u + 13]] + S[d[u + 14]] + S[d[u + 15]]).toLowerCase();
|
|
1735
1735
|
if (!(function(y) {
|
|
1736
1736
|
return typeof y == "string" && m.test(y);
|
|
1737
|
-
})(
|
|
1738
|
-
return
|
|
1737
|
+
})(v)) throw TypeError("Stringified UUID is invalid");
|
|
1738
|
+
return v;
|
|
1739
1739
|
}
|
|
1740
|
-
function I(d, u,
|
|
1740
|
+
function I(d, u, v) {
|
|
1741
1741
|
var y = (d = d || {}).random || (d.rng || b)();
|
|
1742
1742
|
return y[6] = 64 | 15 & y[6], y[8] = 128 | 63 & y[8], g(y);
|
|
1743
1743
|
}
|
|
1744
1744
|
function k(d, u) {
|
|
1745
1745
|
if (!d || !u) return {};
|
|
1746
|
-
const
|
|
1747
|
-
if (
|
|
1748
|
-
const y = u.get(
|
|
1749
|
-
|
|
1746
|
+
const v = { ...d };
|
|
1747
|
+
if (v.localCandidateId) {
|
|
1748
|
+
const y = u.get(v.localCandidateId);
|
|
1749
|
+
v.local = { ...y };
|
|
1750
1750
|
}
|
|
1751
|
-
if (
|
|
1752
|
-
const y = u.get(
|
|
1753
|
-
|
|
1751
|
+
if (v.remoteCandidateId) {
|
|
1752
|
+
const y = u.get(v.remoteCandidateId);
|
|
1753
|
+
v.remote = { ...y };
|
|
1754
1754
|
}
|
|
1755
|
-
return
|
|
1755
|
+
return v;
|
|
1756
1756
|
}
|
|
1757
|
-
function A(d, u,
|
|
1757
|
+
function A(d, u, v) {
|
|
1758
1758
|
return 8 * (function(y, C, R) {
|
|
1759
1759
|
const T = y[R], D = C ? C[R] : null;
|
|
1760
1760
|
return T === null || D === null ? null : (T - D) / (y.timestamp - C.timestamp) * 1e3;
|
|
1761
|
-
})(d, u,
|
|
1761
|
+
})(d, u, v);
|
|
1762
1762
|
}
|
|
1763
1763
|
function P(d) {
|
|
1764
1764
|
if (!d.entries) return d;
|
|
1765
1765
|
const u = {};
|
|
1766
|
-
return d.forEach((function(
|
|
1767
|
-
u[y] =
|
|
1766
|
+
return d.forEach((function(v, y) {
|
|
1767
|
+
u[y] = v;
|
|
1768
1768
|
})), u;
|
|
1769
1769
|
}
|
|
1770
|
-
function M(d, u,
|
|
1770
|
+
function M(d, u, v = {}) {
|
|
1771
1771
|
if (!d) return null;
|
|
1772
1772
|
let y = { audio: { inbound: [], outbound: [] }, video: { inbound: [], outbound: [] }, connection: { inbound: [], outbound: [] } };
|
|
1773
|
-
|
|
1773
|
+
v.remote && (y.remote = { audio: { inbound: [], outbound: [] }, video: { inbound: [], outbound: [] } });
|
|
1774
1774
|
for (const C of d.values()) switch (C.type) {
|
|
1775
1775
|
case "outbound-rtp": {
|
|
1776
1776
|
const R = C.mediaType || C.kind, T = {};
|
|
@@ -1809,7 +1809,7 @@ var Ge, Bi = Li((function(n, e) {
|
|
|
1809
1809
|
y.connection.dataChannelsClosed = C.dataChannelsClosed, y.connection.dataChannelsOpened = C.dataChannelsOpened;
|
|
1810
1810
|
break;
|
|
1811
1811
|
case "remote-inbound-rtp": {
|
|
1812
|
-
if (!
|
|
1812
|
+
if (!v.remote) break;
|
|
1813
1813
|
let R = C.mediaType || C.kind;
|
|
1814
1814
|
const T = {};
|
|
1815
1815
|
if (!["audio", "video"].includes(R)) if (C.id.includes("Video")) R = "video";
|
|
@@ -1832,7 +1832,7 @@ var Ge, Bi = Li((function(n, e) {
|
|
|
1832
1832
|
break;
|
|
1833
1833
|
}
|
|
1834
1834
|
case "remote-outbound-rtp": {
|
|
1835
|
-
if (!
|
|
1835
|
+
if (!v.remote) break;
|
|
1836
1836
|
const R = C.mediaType || C.kind, T = {};
|
|
1837
1837
|
if (!["audio", "video"].includes(R)) continue;
|
|
1838
1838
|
if (C.codecId) {
|
|
@@ -1871,31 +1871,31 @@ var Ge, Bi = Li((function(n, e) {
|
|
|
1871
1871
|
return console.warn("The addPeer() method has been deprecated, please use addConnection()"), this.addConnection({ peerId: d, pc: u });
|
|
1872
1872
|
}
|
|
1873
1873
|
async addConnection(d) {
|
|
1874
|
-
const { pc: u, peerId:
|
|
1874
|
+
const { pc: u, peerId: v } = d;
|
|
1875
1875
|
let { connectionId: y, remote: C } = d;
|
|
1876
1876
|
if (C = typeof C == "boolean" ? C : this.remote, !(u && u instanceof RTCPeerConnection)) throw new Error("Missing argument 'pc' or is not of instance RTCPeerConnection");
|
|
1877
|
-
if (!
|
|
1877
|
+
if (!v) throw new Error("Missing argument peerId");
|
|
1878
1878
|
if (this.isEdge) throw new Error("Can't monitor peers in Edge at this time.");
|
|
1879
|
-
if (this.peersToMonitor[
|
|
1880
|
-
if (y && y in this.peersToMonitor[
|
|
1881
|
-
for (let T in this.peersToMonitor[
|
|
1882
|
-
const D = this.peersToMonitor[
|
|
1883
|
-
if (D.pc === u) throw new Error(`We are already monitoring peer with id ${
|
|
1879
|
+
if (this.peersToMonitor[v]) {
|
|
1880
|
+
if (y && y in this.peersToMonitor[v]) throw new Error(`We are already monitoring connection with id ${y}.`);
|
|
1881
|
+
for (let T in this.peersToMonitor[v]) {
|
|
1882
|
+
const D = this.peersToMonitor[v][T];
|
|
1883
|
+
if (D.pc === u) throw new Error(`We are already monitoring peer with id ${v}.`);
|
|
1884
1884
|
D.pc.connectionState === "closed" && this.removeConnection({ pc: D.pc });
|
|
1885
1885
|
}
|
|
1886
1886
|
}
|
|
1887
1887
|
const R = u.getConfiguration();
|
|
1888
1888
|
return R.iceServers && R.iceServers.forEach((function(T) {
|
|
1889
1889
|
delete T.credential;
|
|
1890
|
-
})), y || (y = I()), this.emitEvent({ event: "addConnection", tag: "peer", peerId:
|
|
1890
|
+
})), y || (y = I()), this.emitEvent({ event: "addConnection", tag: "peer", peerId: v, connectionId: y, data: { options: d, peerConfiguration: R } }), this.monitorPeer({ peerId: v, connectionId: y, pc: u, remote: C }), { connectionId: y };
|
|
1891
1891
|
}
|
|
1892
1892
|
getTimeline(d) {
|
|
1893
|
-
return this.timeline = this.timeline.sort(((u,
|
|
1893
|
+
return this.timeline = this.timeline.sort(((u, v) => u.timestamp.getTime() - v.timestamp.getTime())), d ? this.timeline.filter(((u) => u.tag === d)) : this.timeline;
|
|
1894
1894
|
}
|
|
1895
1895
|
get logger() {
|
|
1896
1896
|
const d = (u) => {
|
|
1897
|
-
const
|
|
1898
|
-
return
|
|
1897
|
+
const v = ["none", "error", "warn", "info", "debug"];
|
|
1898
|
+
return v.slice(0, v.indexOf(this.logLevel) + 1).indexOf(u) > -1;
|
|
1899
1899
|
};
|
|
1900
1900
|
return { error(...u) {
|
|
1901
1901
|
this.debug && d("error") && console.error("[webrtc-stats][error] ", ...u);
|
|
@@ -1908,17 +1908,17 @@ var Ge, Bi = Li((function(n, e) {
|
|
|
1908
1908
|
} };
|
|
1909
1909
|
}
|
|
1910
1910
|
removeConnection(d) {
|
|
1911
|
-
let u, { connectionId:
|
|
1912
|
-
if (!y && !
|
|
1913
|
-
if (
|
|
1914
|
-
if (typeof
|
|
1915
|
-
for (let C in this.peersToMonitor)
|
|
1911
|
+
let u, { connectionId: v, pc: y } = d;
|
|
1912
|
+
if (!y && !v) throw new Error("Missing arguments. You need to either send pc or a connectionId.");
|
|
1913
|
+
if (v) {
|
|
1914
|
+
if (typeof v != "string") throw new Error("connectionId must be a string.");
|
|
1915
|
+
for (let C in this.peersToMonitor) v in this.peersToMonitor[C] && (y = this.peersToMonitor[C][v].pc, u = C);
|
|
1916
1916
|
} else if (y) {
|
|
1917
1917
|
if (!(y instanceof RTCPeerConnection)) throw new Error("pc must be an instance of RTCPeerConnection.");
|
|
1918
|
-
for (let C in this.peersToMonitor) for (let R in this.peersToMonitor[C]) this.peersToMonitor[C][R].pc === y && (
|
|
1918
|
+
for (let C in this.peersToMonitor) for (let R in this.peersToMonitor[C]) this.peersToMonitor[C][R].pc === y && (v = R, u = C);
|
|
1919
1919
|
}
|
|
1920
|
-
if (!y || !
|
|
1921
|
-
return this.removePeerConnectionEventListeners(
|
|
1920
|
+
if (!y || !v) throw new Error("Could not find the desired connection.");
|
|
1921
|
+
return this.removePeerConnectionEventListeners(v, y), delete this.peersToMonitor[u][v], Object.values(this.peersToMonitor[u]).length === 0 && delete this.peersToMonitor[u], { connectionId: v };
|
|
1922
1922
|
}
|
|
1923
1923
|
removeAllPeers() {
|
|
1924
1924
|
for (let d in this.peersToMonitor) this.removePeer(d);
|
|
@@ -1926,8 +1926,8 @@ var Ge, Bi = Li((function(n, e) {
|
|
|
1926
1926
|
removePeer(d) {
|
|
1927
1927
|
if (this.logger.info(`Removing PeerConnection with id ${d}.`), this.peersToMonitor[d]) {
|
|
1928
1928
|
for (let u in this.peersToMonitor[d]) {
|
|
1929
|
-
let
|
|
1930
|
-
this.removePeerConnectionEventListeners(u,
|
|
1929
|
+
let v = this.peersToMonitor[d][u].pc;
|
|
1930
|
+
this.removePeerConnectionEventListeners(u, v);
|
|
1931
1931
|
}
|
|
1932
1932
|
delete this.peersToMonitor[d];
|
|
1933
1933
|
}
|
|
@@ -1938,14 +1938,14 @@ var Ge, Bi = Li((function(n, e) {
|
|
|
1938
1938
|
})), N = [], this.shouldWrapGetUserMedia && Y && (navigator.mediaDevices.getUserMedia = Y);
|
|
1939
1939
|
}
|
|
1940
1940
|
monitorPeer(d) {
|
|
1941
|
-
let { peerId: u, connectionId:
|
|
1941
|
+
let { peerId: u, connectionId: v, pc: y, remote: C } = d;
|
|
1942
1942
|
if (!y) return void this.logger.warn("Did not receive pc argument when calling monitorPeer()");
|
|
1943
|
-
const R = { pc: y, connectionId:
|
|
1943
|
+
const R = { pc: y, connectionId: v, stream: null, stats: { parsed: null, raw: null }, options: { remote: C } };
|
|
1944
1944
|
if (this.peersToMonitor[u]) {
|
|
1945
|
-
if (
|
|
1946
|
-
this.peersToMonitor[u][
|
|
1947
|
-
} else this.peersToMonitor[u] = { [
|
|
1948
|
-
this.addPeerConnectionEventListeners(u,
|
|
1945
|
+
if (v in this.peersToMonitor[u]) return void this.logger.warn(`Already watching connection with ID ${v}`);
|
|
1946
|
+
this.peersToMonitor[u][v] = R;
|
|
1947
|
+
} else this.peersToMonitor[u] = { [v]: R };
|
|
1948
|
+
this.addPeerConnectionEventListeners(u, v, y), this.numberOfMonitoredPeers === 1 && (this.startStatsMonitoring(), this.startConnectionStateMonitoring());
|
|
1949
1949
|
}
|
|
1950
1950
|
startStatsMonitoring() {
|
|
1951
1951
|
this.monitoringSetInterval || (this.monitoringSetInterval = window.setInterval((() => {
|
|
@@ -1966,35 +1966,35 @@ var Ge, Bi = Li((function(n, e) {
|
|
|
1966
1966
|
if (!this.peersToMonitor[d]) throw new Error(`Cannot get stats. Peer with id ${d} does not exist`);
|
|
1967
1967
|
u[d] = this.peersToMonitor[d];
|
|
1968
1968
|
} else u = this.peersToMonitor;
|
|
1969
|
-
let
|
|
1969
|
+
let v = [];
|
|
1970
1970
|
for (const y in u) for (const C in u[y]) {
|
|
1971
1971
|
const R = u[y][C], T = R.pc;
|
|
1972
1972
|
if (T && !this.checkIfConnectionIsClosed(y, C, T)) try {
|
|
1973
1973
|
const D = this.getTimestamp(), F = T.getStats(null);
|
|
1974
1974
|
if (F) {
|
|
1975
1975
|
const X = await F, z = this.getTimestamp(), q = P(X), E = { remote: R.options.remote }, U = M(X, R.stats.parsed, E), $ = { event: "stats", tag: "stats", peerId: y, connectionId: C, timeTaken: z - D, data: U };
|
|
1976
|
-
this.rawStats === !0 && ($.rawStats = X), this.statsObject === !0 && ($.statsObject = q), this.filteredStats === !0 && ($.filteredStats = this.filteroutStats(q)),
|
|
1976
|
+
this.rawStats === !0 && ($.rawStats = X), this.statsObject === !0 && ($.statsObject = q), this.filteredStats === !0 && ($.filteredStats = this.filteroutStats(q)), v.push($), R.stats.parsed = U;
|
|
1977
1977
|
} else this.logger.error(`PeerConnection from peer ${y} did not return any stats data`);
|
|
1978
1978
|
} catch (D) {
|
|
1979
1979
|
this.logger.error(D);
|
|
1980
1980
|
}
|
|
1981
1981
|
}
|
|
1982
|
-
return
|
|
1982
|
+
return v;
|
|
1983
1983
|
}
|
|
1984
1984
|
startConnectionStateMonitoring() {
|
|
1985
1985
|
this.connectionMonitoringSetInterval = window.setInterval((() => {
|
|
1986
1986
|
this.numberOfMonitoredPeers || this.stopConnectionStateMonitoring();
|
|
1987
1987
|
for (const d in this.peersToMonitor) for (const u in this.peersToMonitor[d]) {
|
|
1988
|
-
const
|
|
1989
|
-
this.checkIfConnectionIsClosed(d, u,
|
|
1988
|
+
const v = this.peersToMonitor[d][u].pc;
|
|
1989
|
+
this.checkIfConnectionIsClosed(d, u, v);
|
|
1990
1990
|
}
|
|
1991
1991
|
}), this.connectionMonitoringInterval);
|
|
1992
1992
|
}
|
|
1993
|
-
checkIfConnectionIsClosed(d, u,
|
|
1994
|
-
const y = this.isConnectionClosed(
|
|
1993
|
+
checkIfConnectionIsClosed(d, u, v) {
|
|
1994
|
+
const y = this.isConnectionClosed(v);
|
|
1995
1995
|
if (y) {
|
|
1996
|
-
this.removeConnection({ pc:
|
|
1997
|
-
let C =
|
|
1996
|
+
this.removeConnection({ pc: v });
|
|
1997
|
+
let C = v.connectionState === "closed" ? "onconnectionstatechange" : "oniceconnectionstatechange";
|
|
1998
1998
|
this.emitEvent({ event: C, peerId: d, connectionId: u, tag: "connection", data: "closed" });
|
|
1999
1999
|
}
|
|
2000
2000
|
return y;
|
|
@@ -2016,54 +2016,54 @@ var Ge, Bi = Li((function(n, e) {
|
|
|
2016
2016
|
filteroutStats(d = {}) {
|
|
2017
2017
|
const u = { ...d };
|
|
2018
2018
|
for (const y in u) {
|
|
2019
|
-
var
|
|
2020
|
-
this.statsToMonitor.includes(
|
|
2019
|
+
var v = u[y];
|
|
2020
|
+
this.statsToMonitor.includes(v.type) || delete u[y];
|
|
2021
2021
|
}
|
|
2022
2022
|
return u;
|
|
2023
2023
|
}
|
|
2024
2024
|
get peerConnectionListeners() {
|
|
2025
|
-
return { icecandidate: (d, u,
|
|
2025
|
+
return { icecandidate: (d, u, v, y) => {
|
|
2026
2026
|
this.logger.debug("[pc-event] icecandidate | peerId: ${peerId}", y), this.emitEvent({ event: "onicecandidate", tag: "connection", peerId: d, connectionId: u, data: y.candidate });
|
|
2027
|
-
}, track: (d, u,
|
|
2027
|
+
}, track: (d, u, v, y) => {
|
|
2028
2028
|
this.logger.debug(`[pc-event] track | peerId: ${d}`, y);
|
|
2029
2029
|
const C = y.track, R = y.streams[0];
|
|
2030
2030
|
d in this.peersToMonitor && u in this.peersToMonitor[d] && (this.peersToMonitor[d][u].stream = R), this.addTrackEventListeners(C, u), this.emitEvent({ event: "ontrack", tag: "track", peerId: d, connectionId: u, data: { stream: R ? this.getStreamDetails(R) : null, track: C ? this.getMediaTrackDetails(C) : null, title: y.track.kind + ":" + y.track.id + " " + y.streams.map((function(T) {
|
|
2031
2031
|
return "stream:" + T.id;
|
|
2032
2032
|
})) } });
|
|
2033
|
-
}, signalingstatechange: (d, u,
|
|
2034
|
-
this.logger.debug(`[pc-event] signalingstatechange | peerId: ${d}`), this.emitEvent({ event: "onsignalingstatechange", tag: "connection", peerId: d, connectionId: u, data: { signalingState:
|
|
2035
|
-
}, iceconnectionstatechange: (d, u,
|
|
2036
|
-
this.logger.debug(`[pc-event] iceconnectionstatechange | peerId: ${d}`), this.emitEvent({ event: "oniceconnectionstatechange", tag: "connection", peerId: d, connectionId: u, data:
|
|
2037
|
-
}, icegatheringstatechange: (d, u,
|
|
2038
|
-
this.logger.debug(`[pc-event] icegatheringstatechange | peerId: ${d}`), this.emitEvent({ event: "onicegatheringstatechange", tag: "connection", peerId: d, connectionId: u, data:
|
|
2039
|
-
}, icecandidateerror: (d, u,
|
|
2033
|
+
}, signalingstatechange: (d, u, v) => {
|
|
2034
|
+
this.logger.debug(`[pc-event] signalingstatechange | peerId: ${d}`), this.emitEvent({ event: "onsignalingstatechange", tag: "connection", peerId: d, connectionId: u, data: { signalingState: v.signalingState, localDescription: v.localDescription, remoteDescription: v.remoteDescription } });
|
|
2035
|
+
}, iceconnectionstatechange: (d, u, v) => {
|
|
2036
|
+
this.logger.debug(`[pc-event] iceconnectionstatechange | peerId: ${d}`), this.emitEvent({ event: "oniceconnectionstatechange", tag: "connection", peerId: d, connectionId: u, data: v.iceConnectionState });
|
|
2037
|
+
}, icegatheringstatechange: (d, u, v) => {
|
|
2038
|
+
this.logger.debug(`[pc-event] icegatheringstatechange | peerId: ${d}`), this.emitEvent({ event: "onicegatheringstatechange", tag: "connection", peerId: d, connectionId: u, data: v.iceGatheringState });
|
|
2039
|
+
}, icecandidateerror: (d, u, v, y) => {
|
|
2040
2040
|
this.logger.debug(`[pc-event] icecandidateerror | peerId: ${d}`), this.emitEvent({ event: "onicecandidateerror", tag: "connection", peerId: d, connectionId: u, error: { errorCode: y.errorCode } });
|
|
2041
|
-
}, connectionstatechange: (d, u,
|
|
2042
|
-
this.logger.debug(`[pc-event] connectionstatechange | peerId: ${d}`), this.emitEvent({ event: "onconnectionstatechange", tag: "connection", peerId: d, connectionId: u, data:
|
|
2043
|
-
}, negotiationneeded: (d, u,
|
|
2041
|
+
}, connectionstatechange: (d, u, v) => {
|
|
2042
|
+
this.logger.debug(`[pc-event] connectionstatechange | peerId: ${d}`), this.emitEvent({ event: "onconnectionstatechange", tag: "connection", peerId: d, connectionId: u, data: v.connectionState });
|
|
2043
|
+
}, negotiationneeded: (d, u, v) => {
|
|
2044
2044
|
this.logger.debug(`[pc-event] negotiationneeded | peerId: ${d}`), this.emitEvent({ event: "onnegotiationneeded", tag: "connection", peerId: d, connectionId: u });
|
|
2045
|
-
}, datachannel: (d, u,
|
|
2045
|
+
}, datachannel: (d, u, v, y) => {
|
|
2046
2046
|
this.logger.debug(`[pc-event] datachannel | peerId: ${d}`, y), this.emitEvent({ event: "ondatachannel", tag: "datachannel", peerId: d, connectionId: u, data: y.channel });
|
|
2047
2047
|
} };
|
|
2048
2048
|
}
|
|
2049
|
-
addPeerConnectionEventListeners(d, u,
|
|
2049
|
+
addPeerConnectionEventListeners(d, u, v) {
|
|
2050
2050
|
this.logger.debug(`Adding event listeners for peer ${d} and connection ${u}.`), H[u] = {}, Object.keys(this.peerConnectionListeners).forEach(((y) => {
|
|
2051
|
-
H[u][y] = this.peerConnectionListeners[y].bind(this, d, u,
|
|
2051
|
+
H[u][y] = this.peerConnectionListeners[y].bind(this, d, u, v), v.addEventListener(y, H[u][y], !1);
|
|
2052
2052
|
}));
|
|
2053
2053
|
}
|
|
2054
2054
|
parseGetUserMedia(d) {
|
|
2055
2055
|
try {
|
|
2056
2056
|
const u = { event: "getUserMedia", tag: "getUserMedia", data: { ...d } };
|
|
2057
|
-
d.stream && (u.data.details = this.parseStream(d.stream), d.stream.getTracks().map(((
|
|
2058
|
-
this.addTrackEventListeners(
|
|
2057
|
+
d.stream && (u.data.details = this.parseStream(d.stream), d.stream.getTracks().map(((v) => {
|
|
2058
|
+
this.addTrackEventListeners(v), N.push(v);
|
|
2059
2059
|
}))), this.emitEvent(u);
|
|
2060
2060
|
} catch {
|
|
2061
2061
|
}
|
|
2062
2062
|
}
|
|
2063
2063
|
parseStream(d) {
|
|
2064
2064
|
const u = { audio: [], video: [] };
|
|
2065
|
-
return d.getTracks().forEach(((
|
|
2066
|
-
u[
|
|
2065
|
+
return d.getTracks().forEach(((v) => {
|
|
2066
|
+
u[v.kind].push(this.getMediaTrackDetails(v));
|
|
2067
2067
|
})), u;
|
|
2068
2068
|
}
|
|
2069
2069
|
getMediaTrackDetails(d) {
|
|
@@ -2085,9 +2085,9 @@ var Ge, Bi = Li((function(n, e) {
|
|
|
2085
2085
|
}
|
|
2086
2086
|
addTrackEventListeners(d, u) {
|
|
2087
2087
|
H[d.id] = {};
|
|
2088
|
-
const
|
|
2089
|
-
Object.keys(
|
|
2090
|
-
H[d.id][y] =
|
|
2088
|
+
const v = this.getTrackEventObject(u);
|
|
2089
|
+
Object.keys(v).forEach(((y) => {
|
|
2090
|
+
H[d.id][y] = v[y].bind(this), d.addEventListener(y, H[d.id][y]);
|
|
2091
2091
|
})), H[d.id].readyState = setInterval((() => {
|
|
2092
2092
|
if (d.readyState === "ended") {
|
|
2093
2093
|
let y = new CustomEvent("ended", { detail: { check: "readyState" } });
|
|
@@ -2098,8 +2098,8 @@ var Ge, Bi = Li((function(n, e) {
|
|
|
2098
2098
|
removeTrackEventListeners(d) {
|
|
2099
2099
|
if (d.id in H) {
|
|
2100
2100
|
const u = this.getTrackEventObject();
|
|
2101
|
-
Object.keys(u).forEach(((
|
|
2102
|
-
d.removeEventListener(
|
|
2101
|
+
Object.keys(u).forEach(((v) => {
|
|
2102
|
+
d.removeEventListener(v, H[d.id][v]);
|
|
2103
2103
|
})), clearInterval(H[d.id].readyState), delete H[d.id];
|
|
2104
2104
|
}
|
|
2105
2105
|
}
|
|
@@ -2118,12 +2118,12 @@ var Ge, Bi = Li((function(n, e) {
|
|
|
2118
2118
|
return Object.keys(this.peersToMonitor).length;
|
|
2119
2119
|
}
|
|
2120
2120
|
removePeerConnectionEventListeners(d, u) {
|
|
2121
|
-
d in H && (Object.keys(this.peerConnectionListeners).forEach(((
|
|
2122
|
-
u.removeEventListener(
|
|
2123
|
-
})), delete H[d]), u.getSenders().forEach(((
|
|
2124
|
-
|
|
2125
|
-
})), u.getReceivers().forEach(((
|
|
2126
|
-
|
|
2121
|
+
d in H && (Object.keys(this.peerConnectionListeners).forEach(((v) => {
|
|
2122
|
+
u.removeEventListener(v, H[d][v], !1);
|
|
2123
|
+
})), delete H[d]), u.getSenders().forEach(((v) => {
|
|
2124
|
+
v.track && this.removeTrackEventListeners(v.track);
|
|
2125
|
+
})), u.getReceivers().forEach(((v) => {
|
|
2126
|
+
v.track && this.removeTrackEventListeners(v.track);
|
|
2127
2127
|
}));
|
|
2128
2128
|
}
|
|
2129
2129
|
getTimestamp() {
|
|
@@ -2132,14 +2132,14 @@ var Ge, Bi = Li((function(n, e) {
|
|
|
2132
2132
|
wrapGetDisplayMedia() {
|
|
2133
2133
|
const d = this;
|
|
2134
2134
|
if (navigator.mediaDevices && navigator.mediaDevices.getDisplayMedia) {
|
|
2135
|
-
const u = navigator.mediaDevices.getDisplayMedia.bind(navigator.mediaDevices),
|
|
2135
|
+
const u = navigator.mediaDevices.getDisplayMedia.bind(navigator.mediaDevices), v = function() {
|
|
2136
2136
|
return d.debug("navigator.mediaDevices.getDisplayMedia", null, arguments[0]), u.apply(navigator.mediaDevices, arguments).then((function(y) {
|
|
2137
2137
|
return y;
|
|
2138
2138
|
}), (function(y) {
|
|
2139
2139
|
return d.debug("navigator.mediaDevices.getDisplayMediaOnFailure", null, y.name), Promise.reject(y);
|
|
2140
2140
|
}));
|
|
2141
2141
|
};
|
|
2142
|
-
navigator.mediaDevices.getDisplayMedia =
|
|
2142
|
+
navigator.mediaDevices.getDisplayMedia = v.bind(navigator.mediaDevices);
|
|
2143
2143
|
}
|
|
2144
2144
|
}
|
|
2145
2145
|
};
|
|
@@ -2148,10 +2148,10 @@ var Ge, Bi = Li((function(n, e) {
|
|
|
2148
2148
|
var Ms = Bi.WebRTCStats;
|
|
2149
2149
|
function xs(n) {
|
|
2150
2150
|
const { packetsLost: e, packetsReceived: t, jitter: i, rtt: s } = n, o = (function(c) {
|
|
2151
|
-
const { jitter:
|
|
2151
|
+
const { jitter: f, rtt: p } = c, b = f + p / 2;
|
|
2152
2152
|
return 0.024 * b + 0.11 * (b - 177.3) * (b > 177.3 ? 1 : 0);
|
|
2153
2153
|
})({ rtt: s, jitter: i }), r = (function(c) {
|
|
2154
|
-
const { packetsLost:
|
|
2154
|
+
const { packetsLost: f, packetsReceived: p } = c, b = f / (p + f) * 100;
|
|
2155
2155
|
return 20 * Math.log(1 + b);
|
|
2156
2156
|
})({ packetsLost: e, packetsReceived: t }), a = 93.2 - o - r + 0, l = 1 + 0.035 * a + 7e-6 * a * (a - 60) * (100 - a);
|
|
2157
2157
|
return Math.min(Math.max(l, 1), 5);
|
|
@@ -2179,8 +2179,8 @@ function js(n, e) {
|
|
|
2179
2179
|
let i = !1;
|
|
2180
2180
|
const s = new Ms({ getStatsInterval: 1e3, rawStats: !1, statsObject: !0, filteredStats: !1, remote: !0, debug: !1, logLevel: "warn" }), o = (r) => L(this, void 0, void 0, (function* () {
|
|
2181
2181
|
r.event === "stats" && O(w.StatsFrame, (function({ data: a }) {
|
|
2182
|
-
var l, c,
|
|
2183
|
-
const { audio: g, remote: I } = a, { audio: k } = I, A = (c = (l = k.inbound[0]) === null || l === void 0 ? void 0 : l.jitter) !== null && c !== void 0 ? c : 1 / 0, P = (p = (
|
|
2182
|
+
var l, c, f, p, b, m, S, _;
|
|
2183
|
+
const { audio: g, remote: I } = a, { audio: k } = I, A = (c = (l = k.inbound[0]) === null || l === void 0 ? void 0 : l.jitter) !== null && c !== void 0 ? c : 1 / 0, P = (p = (f = k.inbound[0]) === null || f === void 0 ? void 0 : f.roundTripTime) !== null && p !== void 0 ? p : 1 / 0, M = (m = (b = g.inbound[0]) === null || b === void 0 ? void 0 : b.packetsReceived) !== null && m !== void 0 ? m : -1, Y = (_ = (S = g.inbound[0]) === null || S === void 0 ? void 0 : S.packetsLost) !== null && _ !== void 0 ? _ : -1, H = xs({ jitter: 1e3 * A, rtt: 1e3 * P, packetsLost: Y, packetsReceived: M });
|
|
2184
2184
|
return { jitter: A, rtt: P, mos: H, quality: Ps(H), inboundAudio: g.inbound[0], outboundAudio: g.outbound[0], remoteInboundAudio: k.inbound[0], remoteOutboundAudio: k.outbound[0] };
|
|
2185
2185
|
})(r), n.uuid), yield n.execute(new $s(t, r));
|
|
2186
2186
|
}));
|
|
@@ -2199,7 +2199,7 @@ function js(n, e) {
|
|
|
2199
2199
|
})), stop: (r) => L(this, void 0, void 0, (function* () {
|
|
2200
2200
|
const a = s.getTimeline();
|
|
2201
2201
|
O(w.StatsReport, a, n.uuid), r === "file" && (function(l, c) {
|
|
2202
|
-
const
|
|
2202
|
+
const f = new Blob([JSON.stringify(l)], { type: "application/json" }), p = URL.createObjectURL(f), b = document.createElement("a");
|
|
2203
2203
|
b.href = p, b.download = `${c}.json`, b.click(), URL.revokeObjectURL(p);
|
|
2204
2204
|
})(a, `webrtc-stats-${t}-${Date.now()}`), yield n.execute(new Fs(t, e)), s.removeAllPeers(), s.destroy(), i = !1;
|
|
2205
2205
|
})), reportConnectionStateChange: (r) => {
|
|
@@ -2253,9 +2253,9 @@ class Se {
|
|
|
2253
2253
|
this.type = e, this.options = t, this.onSdpReadyTwice = null, this.statsReporter = null, this.isIceRestarting = !1, this.iceDone = !1, this._negotiating = !1, this._prevConnectionState = null, this._restartedIceOnConnectionStateFailed = !1, this._sleepWakeupIntervalId = null, this._iceGatheringSafetyTimeout = null, this._gatheredCandidatesCount = 0, this._firstMediaTrackMarked = !1, this._timingsCollected = !1, this._iceRestartTimeoutId = null, this.handleConnectionStateChange = () => L(this, void 0, void 0, (function* () {
|
|
2254
2254
|
var r, a;
|
|
2255
2255
|
const { connectionState: l } = this.instance;
|
|
2256
|
-
if (h.info(`[${(/* @__PURE__ */ new Date()).toISOString()}] Connection State changed: ${this._prevConnectionState} -> ${l}`), l !== "failed" && l !== "disconnected" || (this.isDebugEnabled && this.statsReporter && (function(c,
|
|
2256
|
+
if (h.info(`[${(/* @__PURE__ */ new Date()).toISOString()}] Connection State changed: ${this._prevConnectionState} -> ${l}`), l !== "failed" && l !== "disconnected" || (this.isDebugEnabled && this.statsReporter && (function(c, f) {
|
|
2257
2257
|
return L(this, void 0, void 0, (function* () {
|
|
2258
|
-
const p = { connectionState: c.connectionState, previousConnectionState:
|
|
2258
|
+
const p = { connectionState: c.connectionState, previousConnectionState: f, iceConnectionState: c.iceConnectionState, iceGatheringState: c.iceGatheringState, signalingState: c.signalingState }, b = c.getTransceivers();
|
|
2259
2259
|
if (b.length > 0) {
|
|
2260
2260
|
const m = b[0].sender, S = m?.transport;
|
|
2261
2261
|
S && (p.dtlsState = S.state);
|
|
@@ -2368,26 +2368,26 @@ class Se {
|
|
|
2368
2368
|
}
|
|
2369
2369
|
l.sort(((p, b) => p.fromStart - b.fromStart));
|
|
2370
2370
|
const c = [];
|
|
2371
|
-
let
|
|
2372
|
-
for (const p of l) c.push({ label: p.label, fromStart: p.fromStart, delta: p.fromStart -
|
|
2371
|
+
let f = 0;
|
|
2372
|
+
for (const p of l) c.push({ label: p.label, fromStart: p.fromStart, delta: p.fromStart - f }), f = p.fromStart;
|
|
2373
2373
|
return { mode: o, direction: r, steps: c };
|
|
2374
2374
|
})(this.options.id, e, t);
|
|
2375
2375
|
(function(s) {
|
|
2376
2376
|
const { mode: o, direction: r, steps: a } = s, l = `[CallTimings][${r}][${o}]`;
|
|
2377
2377
|
if (a.length === 0) return void h.info(`${l} No timing data collected`);
|
|
2378
|
-
const c = Math.max(...a.map(((S) => S.label.length)), 4) + 2,
|
|
2378
|
+
const c = Math.max(...a.map(((S) => S.label.length)), 4) + 2, f = (S, _) => {
|
|
2379
2379
|
for (; S.length < _; ) S += " ";
|
|
2380
2380
|
return S;
|
|
2381
2381
|
}, p = (S, _) => {
|
|
2382
2382
|
for (; S.length < _; ) S = " " + S;
|
|
2383
2383
|
return S;
|
|
2384
|
-
}, b =
|
|
2384
|
+
}, b = f("Step", c) + p("Delta", 14) + p("From Start", 14);
|
|
2385
2385
|
let m = "";
|
|
2386
2386
|
for (let S = 0; S < b.length; S++) m += "-";
|
|
2387
|
-
h.info(`${l} Call establishment timing breakdown:`), h.info(`${l} ${b}`), h.info(`${l} ${m}`), h.info(`${l} ${
|
|
2387
|
+
h.info(`${l} Call establishment timing breakdown:`), h.info(`${l} ${b}`), h.info(`${l} ${m}`), h.info(`${l} ${f("Call Start", c)}${p("-", 14)}${p("0.00ms", 14)}`);
|
|
2388
2388
|
for (const S of a) {
|
|
2389
2389
|
const _ = S.delta.toFixed(2) + "ms", g = S.fromStart.toFixed(2) + "ms";
|
|
2390
|
-
h.info(`${l} ${
|
|
2390
|
+
h.info(`${l} ${f(S.label, c)}${p(_, 14)}${p(g, 14)}`);
|
|
2391
2391
|
}
|
|
2392
2392
|
h.info(`${l} ${m}`);
|
|
2393
2393
|
})(i), wt(this.options.id);
|
|
@@ -2457,17 +2457,17 @@ class Se {
|
|
|
2457
2457
|
h.info("Local audio tracks constraints: ", c.getConstraints());
|
|
2458
2458
|
})), this.options.video) {
|
|
2459
2459
|
const c = i.getVideoTracks();
|
|
2460
|
-
r = [...o, ...c], h.info("Local video tracks: ", c), typeof this.options.video == "object" && c.forEach(((
|
|
2461
|
-
h.info("Local video tracks constraints: ",
|
|
2460
|
+
r = [...o, ...c], h.info("Local video tracks: ", c), typeof this.options.video == "object" && c.forEach(((f) => {
|
|
2461
|
+
h.info("Local video tracks constraints: ", f.getConstraints());
|
|
2462
2462
|
}));
|
|
2463
2463
|
}
|
|
2464
2464
|
const { audioCodecs: a, videoCodecs: l } = oi(this.options.preferred_codecs);
|
|
2465
2465
|
if (this.isOffer && typeof this.instance.addTransceiver == "function") {
|
|
2466
2466
|
const c = { direction: "sendrecv", streams: [i] };
|
|
2467
|
-
r.forEach(((
|
|
2468
|
-
|
|
2469
|
-
const p = this.instance.addTransceiver(
|
|
2470
|
-
|
|
2467
|
+
r.forEach(((f) => {
|
|
2468
|
+
f.kind === "audio" && (this.options.userVariables.microphoneLabel = f.label), f.kind === "video" && (this.options.userVariables.cameraLabel = f.label);
|
|
2469
|
+
const p = this.instance.addTransceiver(f, c);
|
|
2470
|
+
f.kind === "audio" && a.length > 0 && this._setCodecs(p, a), f.kind === "video" && l.length > 0 && this._setCodecs(p, l);
|
|
2471
2471
|
}));
|
|
2472
2472
|
} else typeof this.instance.addTrack == "function" ? (r.forEach(((c) => {
|
|
2473
2473
|
c.kind === "audio" && (this.options.userVariables.microphoneLabel = c.label), c.kind === "video" && (this.options.userVariables.cameraLabel = c.label), this.instance.addTrack(c, i);
|
|
@@ -2607,8 +2607,8 @@ class qi {
|
|
|
2607
2607
|
}));
|
|
2608
2608
|
}));
|
|
2609
2609
|
};
|
|
2610
|
-
const { iceServers: i, speaker: s, micId: o, micLabel: r, camId: a, camLabel: l, localElement: c, remoteElement:
|
|
2611
|
-
this.options = Object.assign({}, ps, { audio: b, video: m, iceServers: t?.iceServers && Array.isArray(t.iceServers) ? t.iceServers : i, localElement: c, remoteElement:
|
|
2610
|
+
const { iceServers: i, speaker: s, micId: o, micLabel: r, camId: a, camLabel: l, localElement: c, remoteElement: f, options: p, mediaConstraints: { audio: b, video: m }, ringtoneFile: S, ringbackFile: _ } = e;
|
|
2611
|
+
this.options = Object.assign({}, ps, { audio: b, video: m, iceServers: t?.iceServers && Array.isArray(t.iceServers) ? t.iceServers : i, localElement: c, remoteElement: f, micId: o, micLabel: r, camId: a, camLabel: l, speakerId: s, ringtoneFile: S, ringbackFile: _, debug: p.debug, debugOutput: p.debugOutput, trickleIce: p.trickleIce, prefetchIceCandidates: p.prefetchIceCandidates, forceRelayCandidate: p.forceRelayCandidate, keepConnectionAliveOnSocketClose: p.keepConnectionAliveOnSocketClose, mutedMicOnStart: p.mutedMicOnStart }, t), 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._desiredAudioMuted = !!this.options.mutedMicOnStart, this.options.applyDesiredAudioMuteState = this._applyDesiredAudioMuteState.bind(this), this._init(), this.options && (this._ringtone = ii(this.options.ringtoneFile, "_ringtone"), this._ringback = ii(this.options.ringbackFile, "_ringback"));
|
|
2612
2612
|
}
|
|
2613
2613
|
get creatingPeer() {
|
|
2614
2614
|
return this._creatingPeer;
|
|
@@ -2705,9 +2705,9 @@ class qi {
|
|
|
2705
2705
|
hangup(e, t) {
|
|
2706
2706
|
var i, s, o, r, a, l;
|
|
2707
2707
|
return L(this, void 0, void 0, (function* () {
|
|
2708
|
-
const c = e || {},
|
|
2709
|
-
if (this.cause = c.cause || _.cause, this.causeCode = c.causeCode || _.causeCode, this.sipCode = c.sipCode || null, this.sipReason = c.sipReason || null, this.sipCallId = c.sip_call_id || null, this.options.customHeaders = [...(i = this.options.customHeaders) !== null && i !== void 0 ? i : [], ...(o = (s = c?.dialogParams) === null || s === void 0 ? void 0 : s.customHeaders) !== null && o !== void 0 ? o : []], h.debug(`[${this.id}] hangup() invoked`, { callId: this.id, execute:
|
|
2710
|
-
if (this.setState(x.Hangup), this.stopRingtone(), this.stopRingback(),
|
|
2708
|
+
const c = e || {}, f = t !== !1, p = this.state, b = this.prevState, m = this._captureHangupCallerStack(), S = c.initiator || "app:call.hangup", _ = this._state < x.Active ? { cause: "USER_BUSY", causeCode: 17 } : { cause: "NORMAL_CLEARING", causeCode: 16 };
|
|
2709
|
+
if (this.cause = c.cause || _.cause, this.causeCode = c.causeCode || _.causeCode, this.sipCode = c.sipCode || null, this.sipReason = c.sipReason || null, this.sipCallId = c.sip_call_id || null, this.options.customHeaders = [...(i = this.options.customHeaders) !== null && i !== void 0 ? i : [], ...(o = (s = c?.dialogParams) === null || s === void 0 ? void 0 : s.customHeaders) !== null && o !== void 0 ? o : []], h.debug(`[${this.id}] hangup() invoked`, { callId: this.id, execute: f, state: p, prevState: b, cause: this.cause, causeCode: this.causeCode, initiator: S, sipCode: this.sipCode, sipReason: this.sipReason, sipCallId: this.sipCallId, isRecovering: !!c.isRecovering, hasDialogCustomHeaders: !!(!((a = (r = c.dialogParams) === null || r === void 0 ? void 0 : r.customHeaders) === null || a === void 0) && a.length), callerStack: m }), c.isRecovering) return this._isRecovering = !0, this.setState(x.Recovering), void this._finalize();
|
|
2710
|
+
if (this.setState(x.Hangup), this.stopRingtone(), this.stopRingback(), f) {
|
|
2711
2711
|
const g = new bs({ sipCode: this.sipCode, sip_call_id: this.sipCallId, sessid: this.session.sessionid, dialogParams: this.options, cause: this.cause, causeCode: this.causeCode });
|
|
2712
2712
|
let I;
|
|
2713
2713
|
try {
|
|
@@ -2772,10 +2772,10 @@ class qi {
|
|
|
2772
2772
|
const m = G(Ce(b), b);
|
|
2773
2773
|
return void O(w.MediaError, m, ((s = this.options) === null || s === void 0 ? void 0 : s.id) || this.id);
|
|
2774
2774
|
}
|
|
2775
|
-
const
|
|
2776
|
-
|
|
2775
|
+
const f = c.getAudioTracks()[0];
|
|
2776
|
+
f.enabled = !r;
|
|
2777
2777
|
try {
|
|
2778
|
-
yield l.replaceTrack(
|
|
2778
|
+
yield l.replaceTrack(f);
|
|
2779
2779
|
} catch (b) {
|
|
2780
2780
|
const m = G(Ce(b), b);
|
|
2781
2781
|
return O(w.MediaError, m, ((o = this.options) === null || o === void 0 ? void 0 : o.id) || this.id), void c.getTracks().forEach(((S) => S.stop()));
|
|
@@ -2904,8 +2904,8 @@ class qi {
|
|
|
2904
2904
|
switch (i) {
|
|
2905
2905
|
case "bootObj": {
|
|
2906
2906
|
this._lastSerno = 0;
|
|
2907
|
-
const { chatChannel: a, infoChannel: l, modChannel: c, laName:
|
|
2908
|
-
this._dispatchConferenceUpdate({ action: re.Join, conferenceName:
|
|
2907
|
+
const { chatChannel: a, infoChannel: l, modChannel: c, laName: f, conferenceMemberID: p, role: b } = t;
|
|
2908
|
+
this._dispatchConferenceUpdate({ action: re.Join, conferenceName: f, participantId: Number(p), role: b }), a && (yield this._subscribeConferenceChat(a)), l && (yield this._subscribeConferenceInfo(l));
|
|
2909
2909
|
const m = [];
|
|
2910
2910
|
for (const S in s) m.push(Object.assign({ callId: s[S][0], index: Number(S) }, We(s[S][1])));
|
|
2911
2911
|
this._dispatchConferenceUpdate({ action: re.Bootstrap, participants: m });
|
|
@@ -3031,12 +3031,12 @@ class qi {
|
|
|
3031
3031
|
}
|
|
3032
3032
|
performance.mark(W(this.id, "send-sdp")), this._execute(a).then(((c) => {
|
|
3033
3033
|
if (this._isTerminatingOrTerminated()) return void h.debug(`[${this.id}] Ignoring ${r} response because call is ${this.state}`);
|
|
3034
|
-
const { node_id:
|
|
3035
|
-
this._targetNodeId =
|
|
3034
|
+
const { node_id: f = null } = c;
|
|
3035
|
+
this._targetNodeId = f, r === te.Offer ? this.setState(x.Trying) : this.setState(x.Active);
|
|
3036
3036
|
})).catch(((c) => L(this, void 0, void 0, (function* () {
|
|
3037
3037
|
h.error(`${this.id} - Sending ${r} error:`, c);
|
|
3038
|
-
const
|
|
3039
|
-
O(w.Error, { error:
|
|
3038
|
+
const f = G(Ft, c);
|
|
3039
|
+
O(w.Error, { error: f, callId: this.id, sessionId: this.session.sessionid }, this.session.uuid);
|
|
3040
3040
|
try {
|
|
3041
3041
|
yield this.hangup({ cause: "USER_BUSY", causeCode: 17, initiator: "sdk:sdp-send-failure" }, !0);
|
|
3042
3042
|
} catch (p) {
|
|
@@ -3203,8 +3203,8 @@ class qi {
|
|
|
3203
3203
|
const { id: s, userVariables: o, remoteCallerNumber: r, onNotification: a, recoveredCallId: l } = this.options;
|
|
3204
3204
|
var c;
|
|
3205
3205
|
this.options.id = s ? s.toString() : Ie(), this.id = this.options.id, l && (this.recoveredCallId = l, this._isRecovering = !0), o && (c = o, Object.keys(c).length !== 0) || (this.options.userVariables = this.session.options.userVariables || {}), r || (this.options.remoteCallerNumber = this.options.destinationNumber), this.session.calls[this.id] = this, fe(w.MediaError, this._onMediaError, this.id), fe(w.PeerConnectionFailureError, this._onPeerConnectionFailureError, this.id), fe(w.PeerConnectionSignalingStateClosed, this._onPeerConnectionSignalingStateClosed, this.id), Ee(a) && fe(w.Notification, a.bind(this), this.id);
|
|
3206
|
-
const
|
|
3207
|
-
|
|
3206
|
+
const f = this.session.options.enableCallReports !== !1, p = this.session.options.callReportInterval || 5e3, b = (e = this.session.options.callReportFlushInterval) !== null && e !== void 0 ? e : 18e4, m = this.session.options.debugLogLevel || "debug", S = this.session.options.debugLogMaxEntries || 1e3;
|
|
3207
|
+
f && (this._callReportCollector = new B({ enabled: !0, interval: p, intermediateReportInterval: b }, { enabled: !0, level: m, maxEntries: S }), this._callReportCollector.onFlushNeeded = () => {
|
|
3208
3208
|
this._flushIntermediateReport();
|
|
3209
3209
|
}, this._callReportCollector.onWarning = (_) => {
|
|
3210
3210
|
var g, I, k, A;
|
|
@@ -3478,8 +3478,8 @@ class Bs extends ve {
|
|
|
3478
3478
|
return As(s), this._audioConstraints = yield ((o, r, a, l) => L(void 0, void 0, void 0, (function* () {
|
|
3479
3479
|
const { deviceId: c } = l;
|
|
3480
3480
|
if (c === void 0 && (o || r)) {
|
|
3481
|
-
const
|
|
3482
|
-
|
|
3481
|
+
const f = yield it(o, r, a).catch((() => null));
|
|
3482
|
+
f && (l.deviceId = { exact: f });
|
|
3483
3483
|
}
|
|
3484
3484
|
return l;
|
|
3485
3485
|
})))(t, i, "audioinput", s), this.micId = t, this.micLabel = i, this._audioConstraints;
|
|
@@ -3575,14 +3575,14 @@ class Gs {
|
|
|
3575
3575
|
return 1e3 * Pi(2, 6);
|
|
3576
3576
|
}
|
|
3577
3577
|
handleMessage(e) {
|
|
3578
|
-
var t, i, s, o, r, a, l, c,
|
|
3578
|
+
var t, i, s, o, r, a, l, c, f, p, b;
|
|
3579
3579
|
const { session: m } = this;
|
|
3580
3580
|
m.setPingReceived();
|
|
3581
3581
|
const { id: S, method: _, params: g = {}, voice_sdk_id: I } = e, k = g?.callID, A = g?.eventChannel, P = g?.eventType, M = m.calls[k], Y = (t = M?.peer) === null || t === void 0 ? void 0 : t.isConnectionHealthy(), H = new Set(Object.keys(m.calls));
|
|
3582
3582
|
if (Array.isArray(g?.reattached_sessions) && H.size) {
|
|
3583
3583
|
h.debug(`Reattach: active call IDs before cleanup check: [${Array.from(H).join(", ")}].`);
|
|
3584
|
-
const
|
|
3585
|
-
if (
|
|
3584
|
+
const v = g.reattached_sessions.length === 0, y = g.reattached_sessions.some(((C) => H.has(C)));
|
|
3585
|
+
if (v || !y) for (const C of Object.keys(m.calls)) {
|
|
3586
3586
|
const R = m.calls[C];
|
|
3587
3587
|
h.debug(`Session not reattached — terminating active call ${C} `);
|
|
3588
3588
|
const T = G(Mn);
|
|
@@ -3590,10 +3590,10 @@ class Gs {
|
|
|
3590
3590
|
}
|
|
3591
3591
|
}
|
|
3592
3592
|
if (P === "channelPvtData") return this._handlePvtEvent(g.pvtData);
|
|
3593
|
-
const N = ({ recoveredCallId:
|
|
3593
|
+
const N = ({ recoveredCallId: v, forceRelayCandidateForRecovery: y, mutedMicOnStart: C } = {}) => {
|
|
3594
3594
|
var R, T, D, F, X;
|
|
3595
3595
|
const z = { audio: !0, video: m.options.video, remoteSdp: g.sdp, destinationNumber: g.callee_id_number, remoteCallerName: g.caller_id_name, remoteCallerNumber: g.caller_id_number, callerName: g.callee_id_name, callerNumber: g.callee_id_number, attach: _ === j.Attach, mediaSettings: g.mediaSettings, debug: (R = m.options.debug) !== null && R !== void 0 && R, debugOutput: (T = m.options.debugOutput) !== null && T !== void 0 ? T : "socket", trickleIce: (D = m.options.trickleIce) !== null && D !== void 0 && D, prefetchIceCandidates: (F = m.options.prefetchIceCandidates) === null || F === void 0 || F, forceRelayCandidate: y || m.options.forceRelayCandidate || !1, keepConnectionAliveOnSocketClose: (X = m.options.keepConnectionAliveOnSocketClose) !== null && X !== void 0 && X, mutedMicOnStart: C ?? m.options.mutedMicOnStart };
|
|
3596
|
-
k && (z.id = k), g.telnyx_call_control_id && (z.telnyxCallControlId = g.telnyx_call_control_id), g.telnyx_session_id && (z.telnyxSessionId = g.telnyx_session_id), g.telnyx_leg_id && (z.telnyxLegId = g.telnyx_leg_id), g.client_state && (z.clientState = g.client_state), g.dialogParams && g.dialogParams.custom_headers && g.dialogParams.custom_headers.length && (z.customHeaders = g.dialogParams.custom_headers),
|
|
3596
|
+
k && (z.id = k), g.telnyx_call_control_id && (z.telnyxCallControlId = g.telnyx_call_control_id), g.telnyx_session_id && (z.telnyxSessionId = g.telnyx_session_id), g.telnyx_leg_id && (z.telnyxLegId = g.telnyx_leg_id), g.client_state && (z.clientState = g.client_state), g.dialogParams && g.dialogParams.custom_headers && g.dialogParams.custom_headers.length && (z.customHeaders = g.dialogParams.custom_headers), v && (z.recoveredCallId = v), performance.mark(W(z.id, "new-call-start"));
|
|
3597
3597
|
const q = new me(m, z);
|
|
3598
3598
|
return q.nodeId = this.nodeId, q;
|
|
3599
3599
|
}, d = new ji(I), u = new Mt(I);
|
|
@@ -3635,8 +3635,8 @@ class Gs {
|
|
|
3635
3635
|
case j.Event:
|
|
3636
3636
|
case "webrtc.event":
|
|
3637
3637
|
if (!A) return void h.error("Verto received an unknown event:", g);
|
|
3638
|
-
const
|
|
3639
|
-
m._existsSubscription(
|
|
3638
|
+
const v = m.relayProtocol, y = A.split(".")[0];
|
|
3639
|
+
m._existsSubscription(v, A) ? O(v, g, A) : A === m.sessionid ? this._handleSessionEvent(g.eventData) : m._existsSubscription(v, y) ? O(v, g, y) : m.calls.hasOwnProperty(A) ? m.calls[A].handleMessage(e) : O(w.Notification, g, m.uuid);
|
|
3640
3640
|
break;
|
|
3641
3641
|
case j.Info:
|
|
3642
3642
|
g.type = ce.generic, O(w.Notification, g, m.uuid);
|
|
@@ -3659,7 +3659,7 @@ class Gs {
|
|
|
3659
3659
|
R && (m.callReportId = R, h.debug("Captured call_report_id from REGED:", R));
|
|
3660
3660
|
const T = (l = (a = e?.result) === null || a === void 0 ? void 0 : a.params) === null || l === void 0 ? void 0 : l.dc;
|
|
3661
3661
|
T && (m.dc = T);
|
|
3662
|
-
const D = (
|
|
3662
|
+
const D = (f = (c = e?.result) === null || c === void 0 ? void 0 : c.params) === null || f === void 0 ? void 0 : f.region;
|
|
3663
3663
|
D && (m.region = D), h.info(`Connected to Telnyx — region: ${(p = m.region) !== null && p !== void 0 ? p : "unknown"}, dc: ${(b = m.dc) !== null && b !== void 0 ? b : "unknown"}`), g.type = ce.vertoClientReady, O(w.Ready, g, m.uuid);
|
|
3664
3664
|
}
|
|
3665
3665
|
break;
|
|
@@ -3730,7 +3730,7 @@ class Gs {
|
|
|
3730
3730
|
}
|
|
3731
3731
|
_handlePvtEvent(e) {
|
|
3732
3732
|
return L(this, void 0, void 0, (function* () {
|
|
3733
|
-
const { session: t } = this, i = t.relayProtocol, { action: s, laChannel: o, laName: r, chatChannel: a, infoChannel: l, modChannel: c, conferenceMemberID:
|
|
3733
|
+
const { session: t } = this, i = t.relayProtocol, { action: s, laChannel: o, laName: r, chatChannel: a, infoChannel: l, modChannel: c, conferenceMemberID: f, role: p, callID: b } = e;
|
|
3734
3734
|
switch (s) {
|
|
3735
3735
|
case "conference-liveArray-join": {
|
|
3736
3736
|
const m = () => {
|
|
@@ -3756,7 +3756,7 @@ class Gs {
|
|
|
3756
3756
|
if (o && t._existsSubscription(i, o)) {
|
|
3757
3757
|
const { callId: _ = null } = t.subscriptions[i][o];
|
|
3758
3758
|
if (m = t.calls[_] || null, _ !== null) {
|
|
3759
|
-
const g = { type: ce.conferenceUpdate, action: re.Leave, conferenceName: r, participantId: Number(
|
|
3759
|
+
const g = { type: ce.conferenceUpdate, action: re.Leave, conferenceName: r, participantId: Number(f), role: p };
|
|
3760
3760
|
O(w.Notification, g, _, !1) || O(w.Notification, g, t.uuid), m === null && he(w.Notification, null, _);
|
|
3761
3761
|
}
|
|
3762
3762
|
}
|
|
@@ -3870,13 +3870,13 @@ function Ks() {
|
|
|
3870
3870
|
function i() {
|
|
3871
3871
|
}
|
|
3872
3872
|
Object.create && (i.prototype = /* @__PURE__ */ Object.create(null), new i().__proto__ || (t = !1));
|
|
3873
|
-
function s(l, c,
|
|
3874
|
-
this.fn = l, this.context = c, this.once =
|
|
3873
|
+
function s(l, c, f) {
|
|
3874
|
+
this.fn = l, this.context = c, this.once = f || !1;
|
|
3875
3875
|
}
|
|
3876
|
-
function o(l, c,
|
|
3877
|
-
if (typeof
|
|
3876
|
+
function o(l, c, f, p, b) {
|
|
3877
|
+
if (typeof f != "function")
|
|
3878
3878
|
throw new TypeError("The listener must be a function");
|
|
3879
|
-
var m = new s(
|
|
3879
|
+
var m = new s(f, p || l, b), S = t ? t + c : c;
|
|
3880
3880
|
return l._events[S] ? l._events[S].fn ? l._events[S] = [l._events[S], m] : l._events[S].push(m) : (l._events[S] = m, l._eventsCount++), l;
|
|
3881
3881
|
}
|
|
3882
3882
|
function r(l, c) {
|
|
@@ -3886,22 +3886,22 @@ function Ks() {
|
|
|
3886
3886
|
this._events = new i(), this._eventsCount = 0;
|
|
3887
3887
|
}
|
|
3888
3888
|
a.prototype.eventNames = function() {
|
|
3889
|
-
var c = [],
|
|
3889
|
+
var c = [], f, p;
|
|
3890
3890
|
if (this._eventsCount === 0) return c;
|
|
3891
|
-
for (p in
|
|
3892
|
-
e.call(
|
|
3893
|
-
return Object.getOwnPropertySymbols ? c.concat(Object.getOwnPropertySymbols(
|
|
3891
|
+
for (p in f = this._events)
|
|
3892
|
+
e.call(f, p) && c.push(t ? p.slice(1) : p);
|
|
3893
|
+
return Object.getOwnPropertySymbols ? c.concat(Object.getOwnPropertySymbols(f)) : c;
|
|
3894
3894
|
}, a.prototype.listeners = function(c) {
|
|
3895
|
-
var
|
|
3895
|
+
var f = t ? t + c : c, p = this._events[f];
|
|
3896
3896
|
if (!p) return [];
|
|
3897
3897
|
if (p.fn) return [p.fn];
|
|
3898
3898
|
for (var b = 0, m = p.length, S = new Array(m); b < m; b++)
|
|
3899
3899
|
S[b] = p[b].fn;
|
|
3900
3900
|
return S;
|
|
3901
3901
|
}, a.prototype.listenerCount = function(c) {
|
|
3902
|
-
var
|
|
3902
|
+
var f = t ? t + c : c, p = this._events[f];
|
|
3903
3903
|
return p ? p.fn ? 1 : p.length : 0;
|
|
3904
|
-
}, a.prototype.emit = function(c,
|
|
3904
|
+
}, a.prototype.emit = function(c, f, p, b, m, S) {
|
|
3905
3905
|
var _ = t ? t + c : c;
|
|
3906
3906
|
if (!this._events[_]) return !1;
|
|
3907
3907
|
var g = this._events[_], I = arguments.length, k, A;
|
|
@@ -3910,15 +3910,15 @@ function Ks() {
|
|
|
3910
3910
|
case 1:
|
|
3911
3911
|
return g.fn.call(g.context), !0;
|
|
3912
3912
|
case 2:
|
|
3913
|
-
return g.fn.call(g.context,
|
|
3913
|
+
return g.fn.call(g.context, f), !0;
|
|
3914
3914
|
case 3:
|
|
3915
|
-
return g.fn.call(g.context,
|
|
3915
|
+
return g.fn.call(g.context, f, p), !0;
|
|
3916
3916
|
case 4:
|
|
3917
|
-
return g.fn.call(g.context,
|
|
3917
|
+
return g.fn.call(g.context, f, p, b), !0;
|
|
3918
3918
|
case 5:
|
|
3919
|
-
return g.fn.call(g.context,
|
|
3919
|
+
return g.fn.call(g.context, f, p, b, m), !0;
|
|
3920
3920
|
case 6:
|
|
3921
|
-
return g.fn.call(g.context,
|
|
3921
|
+
return g.fn.call(g.context, f, p, b, m, S), !0;
|
|
3922
3922
|
}
|
|
3923
3923
|
for (A = 1, k = new Array(I - 1); A < I; A++)
|
|
3924
3924
|
k[A - 1] = arguments[A];
|
|
@@ -3931,13 +3931,13 @@ function Ks() {
|
|
|
3931
3931
|
g[A].fn.call(g[A].context);
|
|
3932
3932
|
break;
|
|
3933
3933
|
case 2:
|
|
3934
|
-
g[A].fn.call(g[A].context,
|
|
3934
|
+
g[A].fn.call(g[A].context, f);
|
|
3935
3935
|
break;
|
|
3936
3936
|
case 3:
|
|
3937
|
-
g[A].fn.call(g[A].context,
|
|
3937
|
+
g[A].fn.call(g[A].context, f, p);
|
|
3938
3938
|
break;
|
|
3939
3939
|
case 4:
|
|
3940
|
-
g[A].fn.call(g[A].context,
|
|
3940
|
+
g[A].fn.call(g[A].context, f, p, b);
|
|
3941
3941
|
break;
|
|
3942
3942
|
default:
|
|
3943
3943
|
if (!k) for (M = 1, k = new Array(I - 1); M < I; M++)
|
|
@@ -3946,27 +3946,27 @@ function Ks() {
|
|
|
3946
3946
|
}
|
|
3947
3947
|
}
|
|
3948
3948
|
return !0;
|
|
3949
|
-
}, a.prototype.on = function(c,
|
|
3950
|
-
return o(this, c,
|
|
3951
|
-
}, a.prototype.once = function(c,
|
|
3952
|
-
return o(this, c,
|
|
3953
|
-
}, a.prototype.removeListener = function(c,
|
|
3949
|
+
}, a.prototype.on = function(c, f, p) {
|
|
3950
|
+
return o(this, c, f, p, !1);
|
|
3951
|
+
}, a.prototype.once = function(c, f, p) {
|
|
3952
|
+
return o(this, c, f, p, !0);
|
|
3953
|
+
}, a.prototype.removeListener = function(c, f, p, b) {
|
|
3954
3954
|
var m = t ? t + c : c;
|
|
3955
3955
|
if (!this._events[m]) return this;
|
|
3956
|
-
if (!
|
|
3956
|
+
if (!f)
|
|
3957
3957
|
return r(this, m), this;
|
|
3958
3958
|
var S = this._events[m];
|
|
3959
3959
|
if (S.fn)
|
|
3960
|
-
S.fn ===
|
|
3960
|
+
S.fn === f && (!b || S.once) && (!p || S.context === p) && r(this, m);
|
|
3961
3961
|
else {
|
|
3962
3962
|
for (var _ = 0, g = [], I = S.length; _ < I; _++)
|
|
3963
|
-
(S[_].fn !==
|
|
3963
|
+
(S[_].fn !== f || b && !S[_].once || p && S[_].context !== p) && g.push(S[_]);
|
|
3964
3964
|
g.length ? this._events[m] = g.length === 1 ? g[0] : g : r(this, m);
|
|
3965
3965
|
}
|
|
3966
3966
|
return this;
|
|
3967
3967
|
}, a.prototype.removeAllListeners = function(c) {
|
|
3968
|
-
var
|
|
3969
|
-
return c ? (
|
|
3968
|
+
var f;
|
|
3969
|
+
return c ? (f = t ? t + c : c, this._events[f] && r(this, f)) : (this._events = new i(), this._eventsCount = 0), this;
|
|
3970
3970
|
}, a.prototype.off = a.prototype.removeListener, a.prototype.addListener = a.prototype.on, a.prefixed = t, a.EventEmitter = a, n.exports = a;
|
|
3971
3971
|
})(mt)), mt.exports;
|
|
3972
3972
|
}
|
|
@@ -4004,7 +4004,7 @@ function Qs() {
|
|
|
4004
4004
|
function c(_) {
|
|
4005
4005
|
return _ === "debug" && (_ = "log"), typeof console === t ? !1 : _ === "trace" && i ? l : console[_] !== void 0 ? a(console, _) : console.log !== void 0 ? a(console, "log") : e;
|
|
4006
4006
|
}
|
|
4007
|
-
function
|
|
4007
|
+
function f() {
|
|
4008
4008
|
for (var _ = this.getLevel(), g = 0; g < s.length; g++) {
|
|
4009
4009
|
var I = s[g];
|
|
4010
4010
|
this[I] = g < _ ? e : this.methodFactory(I, _, this.name);
|
|
@@ -4014,7 +4014,7 @@ function Qs() {
|
|
|
4014
4014
|
}
|
|
4015
4015
|
function p(_) {
|
|
4016
4016
|
return function() {
|
|
4017
|
-
typeof console !== t && (
|
|
4017
|
+
typeof console !== t && (f.call(this), this[_].apply(this, arguments));
|
|
4018
4018
|
};
|
|
4019
4019
|
}
|
|
4020
4020
|
function b(_, g, I) {
|
|
@@ -4023,8 +4023,8 @@ function Qs() {
|
|
|
4023
4023
|
function m(_, g) {
|
|
4024
4024
|
var I = this, k, A, P, M = "loglevel";
|
|
4025
4025
|
typeof _ == "string" ? M += ":" + _ : typeof _ == "symbol" && (M = void 0);
|
|
4026
|
-
function Y(
|
|
4027
|
-
var y = (s[
|
|
4026
|
+
function Y(v) {
|
|
4027
|
+
var y = (s[v] || "silent").toUpperCase();
|
|
4028
4028
|
if (!(typeof window === t || !M)) {
|
|
4029
4029
|
try {
|
|
4030
4030
|
window.localStorage[M] = y;
|
|
@@ -4038,21 +4038,21 @@ function Qs() {
|
|
|
4038
4038
|
}
|
|
4039
4039
|
}
|
|
4040
4040
|
function H() {
|
|
4041
|
-
var
|
|
4041
|
+
var v;
|
|
4042
4042
|
if (!(typeof window === t || !M)) {
|
|
4043
4043
|
try {
|
|
4044
|
-
|
|
4044
|
+
v = window.localStorage[M];
|
|
4045
4045
|
} catch {
|
|
4046
4046
|
}
|
|
4047
|
-
if (typeof
|
|
4047
|
+
if (typeof v === t)
|
|
4048
4048
|
try {
|
|
4049
4049
|
var y = window.document.cookie, C = encodeURIComponent(M), R = y.indexOf(C + "=");
|
|
4050
|
-
R !== -1 && (
|
|
4050
|
+
R !== -1 && (v = /^([^;]+)/.exec(
|
|
4051
4051
|
y.slice(R + C.length + 1)
|
|
4052
4052
|
)[1]);
|
|
4053
4053
|
} catch {
|
|
4054
4054
|
}
|
|
4055
|
-
return I.levels[
|
|
4055
|
+
return I.levels[v] === void 0 && (v = void 0), v;
|
|
4056
4056
|
}
|
|
4057
4057
|
}
|
|
4058
4058
|
function N() {
|
|
@@ -4067,11 +4067,11 @@ function Qs() {
|
|
|
4067
4067
|
}
|
|
4068
4068
|
}
|
|
4069
4069
|
}
|
|
4070
|
-
function d(
|
|
4071
|
-
var y =
|
|
4070
|
+
function d(v) {
|
|
4071
|
+
var y = v;
|
|
4072
4072
|
if (typeof y == "string" && I.levels[y.toUpperCase()] !== void 0 && (y = I.levels[y.toUpperCase()]), typeof y == "number" && y >= 0 && y <= I.levels.SILENT)
|
|
4073
4073
|
return y;
|
|
4074
|
-
throw new TypeError("log.setLevel() called with invalid level: " +
|
|
4074
|
+
throw new TypeError("log.setLevel() called with invalid level: " + v);
|
|
4075
4075
|
}
|
|
4076
4076
|
I.name = _, I.levels = {
|
|
4077
4077
|
TRACE: 0,
|
|
@@ -4082,25 +4082,25 @@ function Qs() {
|
|
|
4082
4082
|
SILENT: 5
|
|
4083
4083
|
}, I.methodFactory = g || b, I.getLevel = function() {
|
|
4084
4084
|
return P ?? A ?? k;
|
|
4085
|
-
}, I.setLevel = function(
|
|
4086
|
-
return P = d(
|
|
4087
|
-
}, I.setDefaultLevel = function(
|
|
4088
|
-
A = d(
|
|
4085
|
+
}, I.setLevel = function(v, y) {
|
|
4086
|
+
return P = d(v), y !== !1 && Y(P), f.call(I);
|
|
4087
|
+
}, I.setDefaultLevel = function(v) {
|
|
4088
|
+
A = d(v), H() || I.setLevel(v, !1);
|
|
4089
4089
|
}, I.resetLevel = function() {
|
|
4090
|
-
P = null, N(),
|
|
4091
|
-
}, I.enableAll = function(
|
|
4092
|
-
I.setLevel(I.levels.TRACE,
|
|
4093
|
-
}, I.disableAll = function(
|
|
4094
|
-
I.setLevel(I.levels.SILENT,
|
|
4090
|
+
P = null, N(), f.call(I);
|
|
4091
|
+
}, I.enableAll = function(v) {
|
|
4092
|
+
I.setLevel(I.levels.TRACE, v);
|
|
4093
|
+
}, I.disableAll = function(v) {
|
|
4094
|
+
I.setLevel(I.levels.SILENT, v);
|
|
4095
4095
|
}, I.rebuild = function() {
|
|
4096
|
-
if (r !== I && (k = d(r.getLevel())),
|
|
4097
|
-
for (var
|
|
4098
|
-
o[
|
|
4096
|
+
if (r !== I && (k = d(r.getLevel())), f.call(I), r === I)
|
|
4097
|
+
for (var v in o)
|
|
4098
|
+
o[v].rebuild();
|
|
4099
4099
|
}, k = d(
|
|
4100
4100
|
r ? r.getLevel() : "WARN"
|
|
4101
4101
|
);
|
|
4102
4102
|
var u = H();
|
|
4103
|
-
u != null && (P = d(u)),
|
|
4103
|
+
u != null && (P = d(u)), f.call(I);
|
|
4104
4104
|
}
|
|
4105
4105
|
r = new m(), r.getLogger = function(g) {
|
|
4106
4106
|
if (typeof g != "symbol" && typeof g != "string" || g === "")
|
|
@@ -4121,14 +4121,14 @@ function Qs() {
|
|
|
4121
4121
|
})(Je)), Je.exports;
|
|
4122
4122
|
}
|
|
4123
4123
|
var Xs = Qs();
|
|
4124
|
-
const Zs = /* @__PURE__ */ Yi(Xs), eo = () => (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").replace("Z", ""),
|
|
4125
|
-
|
|
4124
|
+
const Zs = /* @__PURE__ */ Yi(Xs), eo = () => (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").replace("Z", ""), K = Zs.getLogger("telnyx-ai-agent"), to = K.methodFactory;
|
|
4125
|
+
K.methodFactory = (n, e, t) => {
|
|
4126
4126
|
const i = to(n, e, t);
|
|
4127
4127
|
return function(...s) {
|
|
4128
4128
|
i(eo(), "-", ...s);
|
|
4129
4129
|
};
|
|
4130
4130
|
};
|
|
4131
|
-
|
|
4131
|
+
K.setLevel("info");
|
|
4132
4132
|
function io(n, e) {
|
|
4133
4133
|
let t = 0;
|
|
4134
4134
|
return (...i) => {
|
|
@@ -4167,7 +4167,7 @@ class ro {
|
|
|
4167
4167
|
this.volumeThreshold = e?.volumeThreshold ?? no, this.silenceDurationMs = e?.silenceDurationMs ?? so, this.minSpeechDurationMs = e?.minSpeechDurationMs ?? oo, this.maxLatencyMs = e?.maxLatencyMs;
|
|
4168
4168
|
}
|
|
4169
4169
|
updateAgentState = io((e) => {
|
|
4170
|
-
|
|
4170
|
+
K.debug("AudioStreamMonitor updateAgentState", e), K.debug("Previous state:", this.lastState), e.state !== this.lastState && (this.lastState = e.state, nt.emit("conversation.agent.state", e));
|
|
4171
4171
|
}, 100);
|
|
4172
4172
|
/**
|
|
4173
4173
|
* Set the remote audio stream (agent's voice) to monitor for speech detection
|
|
@@ -4207,11 +4207,11 @@ class ro {
|
|
|
4207
4207
|
*/
|
|
4208
4208
|
startRemoteMonitor() {
|
|
4209
4209
|
if (!this.remoteStream) {
|
|
4210
|
-
|
|
4210
|
+
K.debug("Remote monitor: no stream, skipping");
|
|
4211
4211
|
return;
|
|
4212
4212
|
}
|
|
4213
|
-
this.monitorStartTime = performance.now(), this.remoteAudioContext = new AudioContext(),
|
|
4214
|
-
|
|
4213
|
+
this.monitorStartTime = performance.now(), this.remoteAudioContext = new AudioContext(), K.debug("Remote AudioContext state:", this.remoteAudioContext.state), this.remoteAudioContext.state === "suspended" && (K.debug("Resuming suspended AudioContext..."), this.remoteAudioContext.resume().then(() => {
|
|
4214
|
+
K.debug("AudioContext resumed, state:", this.remoteAudioContext?.state);
|
|
4215
4215
|
})), this.remoteSource = this.remoteAudioContext.createMediaStreamSource(
|
|
4216
4216
|
this.remoteStream
|
|
4217
4217
|
), this.remoteAnalyser = this.remoteAudioContext.createAnalyser(), this.remoteSource.connect(this.remoteAnalyser);
|
|
@@ -4222,7 +4222,7 @@ class ro {
|
|
|
4222
4222
|
const s = () => {
|
|
4223
4223
|
this.remoteAnalyser?.getByteFrequencyData(t);
|
|
4224
4224
|
const o = t.reduce((a, l) => a + l, 0) / t.length, r = o >= this.volumeThreshold;
|
|
4225
|
-
if (Math.random() < 0.01 &&
|
|
4225
|
+
if (Math.random() < 0.01 && K.debug("Remote audio volume:", o, "threshold:", this.volumeThreshold, "above:", r), r)
|
|
4226
4226
|
if (i)
|
|
4227
4227
|
this.updateAgentState({ state: "speaking" });
|
|
4228
4228
|
else if (this.isFirstAgentSpeech && this.monitorStartTime !== null) {
|
|
@@ -4245,16 +4245,16 @@ class ro {
|
|
|
4245
4245
|
*/
|
|
4246
4246
|
startLocalMonitor() {
|
|
4247
4247
|
if (!this.localStream) {
|
|
4248
|
-
|
|
4248
|
+
K.debug("Local monitor: no stream, skipping");
|
|
4249
4249
|
return;
|
|
4250
4250
|
}
|
|
4251
|
-
this.localAudioContext = new AudioContext(),
|
|
4251
|
+
this.localAudioContext = new AudioContext(), K.debug("Local AudioContext state:", this.localAudioContext.state), this.localAudioContext.state === "suspended" && (K.debug("Resuming suspended local AudioContext..."), this.localAudioContext.resume()), this.localSource = this.localAudioContext.createMediaStreamSource(
|
|
4252
4252
|
this.localStream
|
|
4253
4253
|
), this.localAnalyser = this.localAudioContext.createAnalyser(), this.localSource.connect(this.localAnalyser), this.localAnalyser.fftSize = 512;
|
|
4254
4254
|
const e = new Uint8Array(this.localAnalyser.frequencyBinCount), t = () => {
|
|
4255
4255
|
this.localAnalyser?.getByteFrequencyData(e);
|
|
4256
4256
|
const i = e.reduce((o, r) => o + r, 0) / e.length;
|
|
4257
|
-
if (Math.random() < 0.02 &&
|
|
4257
|
+
if (Math.random() < 0.02 && K.debug("Local audio volume:", i), i >= this.volumeThreshold)
|
|
4258
4258
|
this.userIsSpeaking || (this.userIsSpeaking = !0, this.userSpeechStartTime = performance.now(), this.userSilenceStartTime = null), this.lastUserAudioTime = performance.now();
|
|
4259
4259
|
else if (this.userIsSpeaking && this.lastUserAudioTime !== null && (this.lastUserAudioTime - (this.userSpeechStartTime || this.lastUserAudioTime) >= this.minSpeechDurationMs && this.userSilenceStartTime === null && (this.userSilenceStartTime = this.lastUserAudioTime), performance.now() - this.lastUserAudioTime > this.silenceDurationMs)) {
|
|
4260
4260
|
this.userIsSpeaking = !1, this.userSpeechStartTime = null, this.thinkingStartTime = performance.now();
|
|
@@ -4400,61 +4400,71 @@ class vo {
|
|
|
4400
4400
|
async execute(e) {
|
|
4401
4401
|
const { call_id: t, name: i } = e;
|
|
4402
4402
|
if (this.inFlight.has(t) || this.completed.has(t)) {
|
|
4403
|
-
|
|
4403
|
+
K.debug(
|
|
4404
4404
|
`[client-tools] duplicate function_call ignored (call_id=${t})`
|
|
4405
4405
|
);
|
|
4406
4406
|
return;
|
|
4407
4407
|
}
|
|
4408
|
-
const s = this.generation, o = this.registry.get(i);
|
|
4409
|
-
if (!
|
|
4410
|
-
|
|
4408
|
+
const s = this.generation, o = this.getActiveCall(), r = this.registry.get(i);
|
|
4409
|
+
if (!r) {
|
|
4410
|
+
K.warn(`[client-tools] no handler registered for tool "${i}"`), this.markCompleted(t, s), this.events.onError({ callId: t, toolName: i, reason: "unknown_tool" }), this.sendOutput(
|
|
4411
4411
|
t,
|
|
4412
4412
|
i,
|
|
4413
4413
|
_t("unknown_tool"),
|
|
4414
4414
|
!0,
|
|
4415
|
-
s
|
|
4415
|
+
s,
|
|
4416
|
+
o
|
|
4416
4417
|
);
|
|
4417
4418
|
return;
|
|
4418
4419
|
}
|
|
4419
|
-
let
|
|
4420
|
+
let a;
|
|
4420
4421
|
try {
|
|
4421
|
-
|
|
4422
|
+
a = e.arguments && e.arguments.length > 0 ? JSON.parse(e.arguments) : void 0;
|
|
4422
4423
|
} catch {
|
|
4423
|
-
|
|
4424
|
+
K.warn(
|
|
4424
4425
|
`[client-tools] invalid JSON arguments for tool "${i}" (call_id=${t})`
|
|
4425
4426
|
), this.markCompleted(t, s), this.events.onError({ callId: t, toolName: i, reason: "invalid_arguments" }), this.sendOutput(
|
|
4426
4427
|
t,
|
|
4427
4428
|
i,
|
|
4428
4429
|
_t("invalid_arguments"),
|
|
4429
4430
|
!0,
|
|
4430
|
-
s
|
|
4431
|
+
s,
|
|
4432
|
+
o
|
|
4431
4433
|
);
|
|
4432
4434
|
return;
|
|
4433
4435
|
}
|
|
4434
4436
|
this.inFlight.add(t), this.events.onInvoked({ callId: t, toolName: i });
|
|
4435
|
-
const
|
|
4437
|
+
const l = {
|
|
4436
4438
|
callId: t,
|
|
4437
4439
|
toolName: i,
|
|
4438
4440
|
rawArguments: e.arguments
|
|
4439
4441
|
};
|
|
4440
4442
|
try {
|
|
4441
|
-
const
|
|
4442
|
-
Promise.resolve().then(() =>
|
|
4443
|
+
const c = await this.withTimeout(
|
|
4444
|
+
Promise.resolve().then(() => r(a, l)),
|
|
4443
4445
|
t,
|
|
4444
4446
|
i
|
|
4445
4447
|
);
|
|
4446
4448
|
this.sendOutput(
|
|
4447
4449
|
t,
|
|
4448
4450
|
i,
|
|
4449
|
-
fo(
|
|
4451
|
+
fo(c),
|
|
4450
4452
|
!1,
|
|
4451
|
-
s
|
|
4453
|
+
s,
|
|
4454
|
+
o
|
|
4455
|
+
);
|
|
4456
|
+
} catch (c) {
|
|
4457
|
+
const f = c instanceof ui ? "timeout" : "handler_error";
|
|
4458
|
+
K.warn(
|
|
4459
|
+
`[client-tools] tool "${i}" failed (call_id=${t}, reason=${f})`
|
|
4460
|
+
), this.events.onError({ callId: t, toolName: i, reason: f }), this.sendOutput(
|
|
4461
|
+
t,
|
|
4462
|
+
i,
|
|
4463
|
+
_t(f),
|
|
4464
|
+
!0,
|
|
4465
|
+
s,
|
|
4466
|
+
o
|
|
4452
4467
|
);
|
|
4453
|
-
} catch (l) {
|
|
4454
|
-
const c = l instanceof ui ? "timeout" : "handler_error";
|
|
4455
|
-
J.warn(
|
|
4456
|
-
`[client-tools] tool "${i}" failed (call_id=${t}, reason=${c})`
|
|
4457
|
-
), this.events.onError({ callId: t, toolName: i, reason: c }), this.sendOutput(t, i, _t(c), !0, s);
|
|
4458
4468
|
} finally {
|
|
4459
4469
|
this.inFlight.delete(t), this.markCompleted(t, s);
|
|
4460
4470
|
}
|
|
@@ -4484,30 +4494,42 @@ class vo {
|
|
|
4484
4494
|
* reset/disconnect happened while the handler was running), the result is
|
|
4485
4495
|
* considered stale and is dropped — sending it would leak the old result
|
|
4486
4496
|
* into a freshly reconnected call/session.
|
|
4497
|
+
*
|
|
4498
|
+
* The result is also dropped when the currently active call is no longer the
|
|
4499
|
+
* one that originated the invocation. This covers the same-WebSocket case
|
|
4500
|
+
* where a conversation is hung up and a new one started before a slow handler
|
|
4501
|
+
* resolves: no reset() fires (the socket stayed open), but the late output
|
|
4502
|
+
* must not be sent against the new conversation's call.
|
|
4487
4503
|
*/
|
|
4488
|
-
sendOutput(e, t, i, s, o) {
|
|
4504
|
+
sendOutput(e, t, i, s, o, r) {
|
|
4489
4505
|
if (this.generation !== o) {
|
|
4490
|
-
|
|
4506
|
+
K.warn(
|
|
4491
4507
|
`[client-tools] dropping stale output after reset (call_id=${e})`
|
|
4492
4508
|
), this.events.onError({ callId: e, toolName: t, reason: "shutdown" });
|
|
4493
4509
|
return;
|
|
4494
4510
|
}
|
|
4495
|
-
const
|
|
4496
|
-
if (!
|
|
4497
|
-
|
|
4511
|
+
const a = this.getActiveCall();
|
|
4512
|
+
if (!a) {
|
|
4513
|
+
K.warn(
|
|
4498
4514
|
`[client-tools] no active call to send output (call_id=${e})`
|
|
4499
4515
|
), this.events.onError({ callId: e, toolName: t, reason: "shutdown" });
|
|
4500
4516
|
return;
|
|
4501
4517
|
}
|
|
4518
|
+
if (!r || a !== r) {
|
|
4519
|
+
K.warn(
|
|
4520
|
+
`[client-tools] dropping stale output after call change (call_id=${e})`
|
|
4521
|
+
), this.events.onError({ callId: e, toolName: t, reason: "shutdown" });
|
|
4522
|
+
return;
|
|
4523
|
+
}
|
|
4502
4524
|
try {
|
|
4503
|
-
|
|
4525
|
+
a.sendAIConversationMessage({
|
|
4504
4526
|
type: "function_call_output",
|
|
4505
4527
|
call_id: e,
|
|
4506
4528
|
output: i
|
|
4507
4529
|
}), this.events.onCompleted({ callId: e, toolName: t, isError: s });
|
|
4508
|
-
} catch (
|
|
4509
|
-
|
|
4510
|
-
`[client-tools] failed to send output for "${t}" (call_id=${e}): ${
|
|
4530
|
+
} catch (l) {
|
|
4531
|
+
K.warn(
|
|
4532
|
+
`[client-tools] failed to send output for "${t}" (call_id=${e}): ${l instanceof Error ? l.message : "unknown error"}`
|
|
4511
4533
|
), this.events.onError({ callId: e, toolName: t, reason: "shutdown" });
|
|
4512
4534
|
}
|
|
4513
4535
|
}
|
|
@@ -4626,7 +4648,7 @@ class pi extends Pt {
|
|
|
4626
4648
|
*/
|
|
4627
4649
|
callReportId = null;
|
|
4628
4650
|
constructor(e) {
|
|
4629
|
-
super(), this.agentId = e.agentId, this.versionId = e.versionId || "main", this.widgetVersion = e.widgetVersion, this.conversationId = e.conversationId, this.debug = e.debug || !1, this.chatMode = e.chatMode || !1, this.activeCall = null,
|
|
4651
|
+
super(), this.agentId = e.agentId, this.versionId = e.versionId || "main", this.widgetVersion = e.widgetVersion, this.conversationId = e.conversationId, this.debug = e.debug || !1, this.chatMode = e.chatMode || !1, this.activeCall = null, K.setLevel(this.debug ? "debug" : "info");
|
|
4630
4652
|
const t = {
|
|
4631
4653
|
target_id: e.agentId,
|
|
4632
4654
|
target_type: "ai_assistant",
|
|
@@ -4750,7 +4772,7 @@ class pi extends Pt {
|
|
|
4750
4772
|
*/
|
|
4751
4773
|
sendConversationMessage(e, t = []) {
|
|
4752
4774
|
if (!this.activeCall) {
|
|
4753
|
-
|
|
4775
|
+
K.error("No active call to send message.");
|
|
4754
4776
|
return;
|
|
4755
4777
|
}
|
|
4756
4778
|
this.activeCall.sendConversationMessage(e, t);
|
|
@@ -4790,13 +4812,13 @@ class pi extends Pt {
|
|
|
4790
4812
|
async startConversation(e) {
|
|
4791
4813
|
if (!this.telnyxRTC) {
|
|
4792
4814
|
const c = new Error("Client is not initialized.");
|
|
4793
|
-
throw
|
|
4815
|
+
throw K.error(c.message), this.emit("agent.error", c), c;
|
|
4794
4816
|
}
|
|
4795
4817
|
if (!this.authenticated || !this.sessionId) {
|
|
4796
4818
|
const c = new Error(
|
|
4797
4819
|
"Cannot start AI agent conversation before login is complete."
|
|
4798
4820
|
);
|
|
4799
|
-
throw
|
|
4821
|
+
throw K.warn(c.message), this.emit("agent.error", c), c;
|
|
4800
4822
|
}
|
|
4801
4823
|
const i = RTCRtpReceiver.getCapabilities("audio")?.codecs?.find(
|
|
4802
4824
|
(c) => c.mimeType.toLowerCase().includes("opus")
|
|
@@ -4854,7 +4876,7 @@ class pi extends Pt {
|
|
|
4854
4876
|
let a = !0, l = 0;
|
|
4855
4877
|
const c = (b) => {
|
|
4856
4878
|
l === b && (this.authenticating = !1);
|
|
4857
|
-
},
|
|
4879
|
+
}, f = function(b) {
|
|
4858
4880
|
const m = yo(b), S = l;
|
|
4859
4881
|
return m && bo(b, r), t.call(this, b).then((_) => {
|
|
4860
4882
|
const g = m ? hi(_) : void 0;
|
|
@@ -4872,8 +4894,8 @@ class pi extends Pt {
|
|
|
4872
4894
|
a && e.login === p && c(m);
|
|
4873
4895
|
});
|
|
4874
4896
|
};
|
|
4875
|
-
return e.execute =
|
|
4876
|
-
a = !1, e.execute ===
|
|
4897
|
+
return e.execute = f, e.login = p, () => {
|
|
4898
|
+
a = !1, e.execute === f && (e.execute = t), e.login === p && (e.login = i);
|
|
4877
4899
|
};
|
|
4878
4900
|
}
|
|
4879
4901
|
emitLoginStarted(e) {
|
|
@@ -4935,7 +4957,7 @@ function Co() {
|
|
|
4935
4957
|
function n(E) {
|
|
4936
4958
|
if (E == null) return null;
|
|
4937
4959
|
if (typeof E == "function")
|
|
4938
|
-
return E.$$typeof ===
|
|
4960
|
+
return E.$$typeof === v ? null : E.displayName || E.name || null;
|
|
4939
4961
|
if (typeof E == "string") return E;
|
|
4940
4962
|
switch (E) {
|
|
4941
4963
|
case g:
|
|
@@ -5039,14 +5061,14 @@ function Co() {
|
|
|
5039
5061
|
)), E = this.props.ref, E !== void 0 ? E : null;
|
|
5040
5062
|
}
|
|
5041
5063
|
function c(E, U, $, V, Z, ie) {
|
|
5042
|
-
var
|
|
5064
|
+
var J = $.ref;
|
|
5043
5065
|
return E = {
|
|
5044
5066
|
$$typeof: S,
|
|
5045
5067
|
type: E,
|
|
5046
5068
|
key: U,
|
|
5047
5069
|
props: $,
|
|
5048
5070
|
_owner: V
|
|
5049
|
-
}, (
|
|
5071
|
+
}, (J !== void 0 ? J : null) !== null ? Object.defineProperty(E, "ref", {
|
|
5050
5072
|
enumerable: !1,
|
|
5051
5073
|
get: l
|
|
5052
5074
|
}) : Object.defineProperty(E, "ref", { enumerable: !1, value: null }), E._store = {}, Object.defineProperty(E._store, "validated", {
|
|
@@ -5071,25 +5093,25 @@ function Co() {
|
|
|
5071
5093
|
value: ie
|
|
5072
5094
|
}), Object.freeze && (Object.freeze(E.props), Object.freeze(E)), E;
|
|
5073
5095
|
}
|
|
5074
|
-
function
|
|
5075
|
-
var
|
|
5076
|
-
if (
|
|
5096
|
+
function f(E, U, $, V, Z, ie) {
|
|
5097
|
+
var J = U.children;
|
|
5098
|
+
if (J !== void 0)
|
|
5077
5099
|
if (V)
|
|
5078
|
-
if (R(
|
|
5079
|
-
for (V = 0; V <
|
|
5080
|
-
p(
|
|
5081
|
-
Object.freeze && Object.freeze(
|
|
5100
|
+
if (R(J)) {
|
|
5101
|
+
for (V = 0; V < J.length; V++)
|
|
5102
|
+
p(J[V]);
|
|
5103
|
+
Object.freeze && Object.freeze(J);
|
|
5082
5104
|
} else
|
|
5083
5105
|
console.error(
|
|
5084
5106
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
5085
5107
|
);
|
|
5086
|
-
else p(
|
|
5108
|
+
else p(J);
|
|
5087
5109
|
if (C.call(U, "key")) {
|
|
5088
|
-
|
|
5110
|
+
J = n(E);
|
|
5089
5111
|
var de = Object.keys(U).filter(function(ln) {
|
|
5090
5112
|
return ln !== "key";
|
|
5091
5113
|
});
|
|
5092
|
-
V = 0 < de.length ? "{key: someKey, " + de.join(": ..., ") + ": ...}" : "{key: someKey}", q[
|
|
5114
|
+
V = 0 < de.length ? "{key: someKey, " + de.join(": ..., ") + ": ...}" : "{key: someKey}", q[J + V] || (de = 0 < de.length ? "{" + de.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
5093
5115
|
`A props object containing a "key" prop is being spread into JSX:
|
|
5094
5116
|
let props = %s;
|
|
5095
5117
|
<%s {...props} />
|
|
@@ -5097,22 +5119,22 @@ React keys must be passed directly to JSX without using spread:
|
|
|
5097
5119
|
let props = %s;
|
|
5098
5120
|
<%s key={someKey} {...props} />`,
|
|
5099
5121
|
V,
|
|
5100
|
-
|
|
5122
|
+
J,
|
|
5101
5123
|
de,
|
|
5102
|
-
|
|
5103
|
-
), q[
|
|
5124
|
+
J
|
|
5125
|
+
), q[J + V] = !0);
|
|
5104
5126
|
}
|
|
5105
|
-
if (
|
|
5127
|
+
if (J = null, $ !== void 0 && (t($), J = "" + $), r(U) && (t(U.key), J = "" + U.key), "key" in U) {
|
|
5106
5128
|
$ = {};
|
|
5107
5129
|
for (var pt in U)
|
|
5108
5130
|
pt !== "key" && ($[pt] = U[pt]);
|
|
5109
5131
|
} else $ = U;
|
|
5110
|
-
return
|
|
5132
|
+
return J && a(
|
|
5111
5133
|
$,
|
|
5112
5134
|
typeof E == "function" ? E.displayName || E.name || "Unknown" : E
|
|
5113
5135
|
), c(
|
|
5114
5136
|
E,
|
|
5115
|
-
|
|
5137
|
+
J,
|
|
5116
5138
|
$,
|
|
5117
5139
|
s(),
|
|
5118
5140
|
Z,
|
|
@@ -5125,7 +5147,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
5125
5147
|
function b(E) {
|
|
5126
5148
|
return typeof E == "object" && E !== null && E.$$typeof === S;
|
|
5127
5149
|
}
|
|
5128
|
-
var m = Lt, S = Symbol.for("react.transitional.element"), _ = Symbol.for("react.portal"), g = Symbol.for("react.fragment"), I = Symbol.for("react.strict_mode"), k = Symbol.for("react.profiler"), A = Symbol.for("react.consumer"), P = Symbol.for("react.context"), M = Symbol.for("react.forward_ref"), Y = Symbol.for("react.suspense"), H = Symbol.for("react.suspense_list"), N = Symbol.for("react.memo"), d = Symbol.for("react.lazy"), u = Symbol.for("react.activity"),
|
|
5150
|
+
var m = Lt, S = Symbol.for("react.transitional.element"), _ = Symbol.for("react.portal"), g = Symbol.for("react.fragment"), I = Symbol.for("react.strict_mode"), k = Symbol.for("react.profiler"), A = Symbol.for("react.consumer"), P = Symbol.for("react.context"), M = Symbol.for("react.forward_ref"), Y = Symbol.for("react.suspense"), H = Symbol.for("react.suspense_list"), N = Symbol.for("react.memo"), d = Symbol.for("react.lazy"), u = Symbol.for("react.activity"), v = Symbol.for("react.client.reference"), y = m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, C = Object.prototype.hasOwnProperty, R = Array.isArray, T = console.createTask ? console.createTask : function() {
|
|
5129
5151
|
return null;
|
|
5130
5152
|
};
|
|
5131
5153
|
m = {
|
|
@@ -5139,7 +5161,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
5139
5161
|
)(), z = T(i(o)), q = {};
|
|
5140
5162
|
Ae.Fragment = g, Ae.jsx = function(E, U, $) {
|
|
5141
5163
|
var V = 1e4 > y.recentlyCreatedOwnerStacks++;
|
|
5142
|
-
return
|
|
5164
|
+
return f(
|
|
5143
5165
|
E,
|
|
5144
5166
|
U,
|
|
5145
5167
|
$,
|
|
@@ -5149,7 +5171,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
5149
5171
|
);
|
|
5150
5172
|
}, Ae.jsxs = function(E, U, $) {
|
|
5151
5173
|
var V = 1e4 > y.recentlyCreatedOwnerStacks++;
|
|
5152
|
-
return
|
|
5174
|
+
return f(
|
|
5153
5175
|
E,
|
|
5154
5176
|
U,
|
|
5155
5177
|
$,
|
|
@@ -5239,28 +5261,28 @@ const To = (n, e, ...t) => e.read(...t), ko = (n, e, ...t) => e.write(...t), Ro
|
|
|
5239
5261
|
let a = s.get(e);
|
|
5240
5262
|
return a || (a = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, s.set(e, a), (t = o.i) == null || t.call(o, e), r?.(n, e)), a;
|
|
5241
5263
|
}, Lo = (n) => {
|
|
5242
|
-
const e = ne(n), t = e[1], i = e[3], s = e[4], o = e[5], r = e[6], a = e[13], l = [], c = (
|
|
5264
|
+
const e = ne(n), t = e[1], i = e[3], s = e[4], o = e[5], r = e[6], a = e[13], l = [], c = (f) => {
|
|
5243
5265
|
try {
|
|
5244
|
-
|
|
5266
|
+
f();
|
|
5245
5267
|
} catch (p) {
|
|
5246
5268
|
l.push(p);
|
|
5247
5269
|
}
|
|
5248
5270
|
};
|
|
5249
5271
|
do {
|
|
5250
5272
|
r.f && c(r.f);
|
|
5251
|
-
const
|
|
5273
|
+
const f = /* @__PURE__ */ new Set(), p = f.add.bind(f);
|
|
5252
5274
|
i.forEach((b) => {
|
|
5253
5275
|
var m;
|
|
5254
5276
|
return (m = t.get(b)) == null ? void 0 : m.l.forEach(p);
|
|
5255
|
-
}), i.clear(), o.forEach(p), o.clear(), s.forEach(p), s.clear(),
|
|
5277
|
+
}), i.clear(), o.forEach(p), o.clear(), s.forEach(p), s.clear(), f.forEach(c), i.size && a(n);
|
|
5256
5278
|
} while (i.size || o.size || s.size);
|
|
5257
5279
|
if (l.length)
|
|
5258
5280
|
throw new AggregateError(l);
|
|
5259
5281
|
}, Do = (n) => {
|
|
5260
|
-
const e = ne(n), t = e[1], i = e[2], s = e[3], o = e[11], r = e[14], a = e[17], l = [], c = /* @__PURE__ */ new WeakSet(),
|
|
5282
|
+
const e = ne(n), t = e[1], i = e[2], s = e[3], o = e[11], r = e[14], a = e[17], l = [], c = /* @__PURE__ */ new WeakSet(), f = /* @__PURE__ */ new WeakSet(), p = Array.from(s);
|
|
5261
5283
|
for (; p.length; ) {
|
|
5262
5284
|
const b = p[p.length - 1], m = o(n, b);
|
|
5263
|
-
if (
|
|
5285
|
+
if (f.has(b)) {
|
|
5264
5286
|
p.pop();
|
|
5265
5287
|
continue;
|
|
5266
5288
|
}
|
|
@@ -5269,7 +5291,7 @@ const To = (n, e, ...t) => e.read(...t), ko = (n, e, ...t) => e.write(...t), Ro
|
|
|
5269
5291
|
l.push([b, m]);
|
|
5270
5292
|
else if ((ge ? "production" : void 0) !== "production" && i.has(b))
|
|
5271
5293
|
throw new Error("[Bug] invalidated atom exists");
|
|
5272
|
-
|
|
5294
|
+
f.add(b), p.pop();
|
|
5273
5295
|
continue;
|
|
5274
5296
|
}
|
|
5275
5297
|
c.add(b);
|
|
@@ -5288,7 +5310,7 @@ const To = (n, e, ...t) => e.read(...t), ko = (n, e, ...t) => e.write(...t), Ro
|
|
|
5288
5310
|
}
|
|
5289
5311
|
}, Rt = /* @__PURE__ */ new WeakSet(), No = (n, e) => {
|
|
5290
5312
|
var t, i;
|
|
5291
|
-
const s = ne(n), o = s[1], r = s[2], a = s[3], l = s[6], c = s[7],
|
|
5313
|
+
const s = ne(n), o = s[1], r = s[2], a = s[3], l = s[6], c = s[7], f = s[11], p = s[12], b = s[13], m = s[14], S = s[16], _ = s[17], g = f(n, e);
|
|
5292
5314
|
if (mi(g)) {
|
|
5293
5315
|
if (o.has(e) && r.get(e) !== g.n)
|
|
5294
5316
|
return g;
|
|
@@ -5309,13 +5331,13 @@ const To = (n, e, ...t) => e.read(...t), ko = (n, e, ...t) => e.write(...t), Ro
|
|
|
5309
5331
|
function A(N) {
|
|
5310
5332
|
var d;
|
|
5311
5333
|
if (N === e) {
|
|
5312
|
-
const
|
|
5313
|
-
if (!mi(
|
|
5334
|
+
const v = f(n, N);
|
|
5335
|
+
if (!mi(v))
|
|
5314
5336
|
if (Ki(N))
|
|
5315
5337
|
at(n, N, N.init);
|
|
5316
5338
|
else
|
|
5317
5339
|
throw new Error("no atom init");
|
|
5318
|
-
return st(
|
|
5340
|
+
return st(v);
|
|
5319
5341
|
}
|
|
5320
5342
|
const u = m(n, N);
|
|
5321
5343
|
try {
|
|
@@ -5356,14 +5378,14 @@ const To = (n, e, ...t) => e.read(...t), ko = (n, e, ...t) => e.write(...t), Ro
|
|
|
5356
5378
|
for (; r.length; ) {
|
|
5357
5379
|
const a = r.pop(), l = o(n, a);
|
|
5358
5380
|
for (const c of Qi(a, l, i)) {
|
|
5359
|
-
const
|
|
5360
|
-
s.set(c,
|
|
5381
|
+
const f = o(n, c);
|
|
5382
|
+
s.set(c, f.n), r.push(c);
|
|
5361
5383
|
}
|
|
5362
5384
|
}
|
|
5363
5385
|
}, Xi = (n, e, ...t) => {
|
|
5364
|
-
const i = ne(n), s = i[3], o = i[6], r = i[8], a = i[11], l = i[12], c = i[13],
|
|
5386
|
+
const i = ne(n), s = i[3], o = i[6], r = i[8], a = i[11], l = i[12], c = i[13], f = i[14], p = i[15], b = i[17];
|
|
5365
5387
|
let m = !0;
|
|
5366
|
-
const S = (g) => st(
|
|
5388
|
+
const S = (g) => st(f(n, g)), _ = (g, ...I) => {
|
|
5367
5389
|
var k;
|
|
5368
5390
|
const A = a(n, g);
|
|
5369
5391
|
try {
|
|
@@ -5387,7 +5409,7 @@ const To = (n, e, ...t) => e.read(...t), ko = (n, e, ...t) => e.write(...t), Ro
|
|
|
5387
5409
|
}
|
|
5388
5410
|
}, xo = (n, e) => {
|
|
5389
5411
|
var t;
|
|
5390
|
-
const i = ne(n), s = i[1], o = i[3], r = i[6], a = i[11], l = i[15], c = i[18],
|
|
5412
|
+
const i = ne(n), s = i[1], o = i[3], r = i[6], a = i[11], l = i[15], c = i[18], f = i[19], p = a(n, e), b = s.get(e);
|
|
5391
5413
|
if (b && !Ji(p.v)) {
|
|
5392
5414
|
for (const [m, S] of p.d)
|
|
5393
5415
|
if (!b.d.has(m)) {
|
|
@@ -5397,13 +5419,13 @@ const To = (n, e, ...t) => e.read(...t), ko = (n, e, ...t) => e.write(...t), Ro
|
|
|
5397
5419
|
for (const m of b.d)
|
|
5398
5420
|
if (!p.d.has(m)) {
|
|
5399
5421
|
b.d.delete(m);
|
|
5400
|
-
const S =
|
|
5422
|
+
const S = f(n, m);
|
|
5401
5423
|
S?.t.delete(e);
|
|
5402
5424
|
}
|
|
5403
5425
|
}
|
|
5404
5426
|
}, Zi = (n, e) => {
|
|
5405
5427
|
var t;
|
|
5406
|
-
const i = ne(n), s = i[1], o = i[4], r = i[6], a = i[10], l = i[11], c = i[12],
|
|
5428
|
+
const i = ne(n), s = i[1], o = i[4], r = i[6], a = i[10], l = i[11], c = i[12], f = i[13], p = i[14], b = i[16], m = l(n, e);
|
|
5407
5429
|
let S = s.get(e);
|
|
5408
5430
|
if (!S) {
|
|
5409
5431
|
p(n, e);
|
|
@@ -5420,7 +5442,7 @@ const To = (n, e, ...t) => e.read(...t), ko = (n, e, ...t) => e.write(...t), Ro
|
|
|
5420
5442
|
try {
|
|
5421
5443
|
return b(n, e, ...k);
|
|
5422
5444
|
} finally {
|
|
5423
|
-
g || (
|
|
5445
|
+
g || (f(n), c(n));
|
|
5424
5446
|
}
|
|
5425
5447
|
};
|
|
5426
5448
|
try {
|
|
@@ -5444,7 +5466,7 @@ const To = (n, e, ...t) => e.read(...t), ko = (n, e, ...t) => e.write(...t), Ro
|
|
|
5444
5466
|
return S;
|
|
5445
5467
|
}, Po = (n, e) => {
|
|
5446
5468
|
var t, i;
|
|
5447
|
-
const s = ne(n), o = s[1], r = s[5], a = s[6], l = s[11], c = s[19],
|
|
5469
|
+
const s = ne(n), o = s[1], r = s[5], a = s[6], l = s[11], c = s[19], f = l(n, e);
|
|
5448
5470
|
let p = o.get(e);
|
|
5449
5471
|
if (!p || p.l.size)
|
|
5450
5472
|
return p;
|
|
@@ -5456,7 +5478,7 @@ const To = (n, e, ...t) => e.read(...t), ko = (n, e, ...t) => e.write(...t), Ro
|
|
|
5456
5478
|
}
|
|
5457
5479
|
if (!b) {
|
|
5458
5480
|
p.u && r.add(p.u), p = void 0, o.delete(e);
|
|
5459
|
-
for (const m of
|
|
5481
|
+
for (const m of f.d.keys()) {
|
|
5460
5482
|
const S = c(n, m);
|
|
5461
5483
|
S?.t.delete(e);
|
|
5462
5484
|
}
|
|
@@ -5604,10 +5626,10 @@ const At = (n) => typeof n?.then == "function", Ot = (n) => {
|
|
|
5604
5626
|
let t = St.get(n);
|
|
5605
5627
|
return t || (t = new Promise((i, s) => {
|
|
5606
5628
|
let o = n;
|
|
5607
|
-
const r = (c) => (
|
|
5608
|
-
o === c && i(
|
|
5609
|
-
}, a = (c) => (
|
|
5610
|
-
o === c && s(
|
|
5629
|
+
const r = (c) => (f) => {
|
|
5630
|
+
o === c && i(f);
|
|
5631
|
+
}, a = (c) => (f) => {
|
|
5632
|
+
o === c && s(f);
|
|
5611
5633
|
}, l = () => {
|
|
5612
5634
|
try {
|
|
5613
5635
|
const c = e();
|
|
@@ -5621,16 +5643,16 @@ const At = (n) => typeof n?.then == "function", Ot = (n) => {
|
|
|
5621
5643
|
};
|
|
5622
5644
|
function dt(n, e) {
|
|
5623
5645
|
const { delay: t, unstable_promiseStatus: i = !Lt.use } = {}, s = nn(), [[o, r, a], l] = dn(
|
|
5624
|
-
(
|
|
5646
|
+
(f) => {
|
|
5625
5647
|
const p = s.get(n);
|
|
5626
|
-
return Object.is(
|
|
5648
|
+
return Object.is(f[0], p) && f[1] === s && f[2] === n ? f : [p, s, n];
|
|
5627
5649
|
},
|
|
5628
5650
|
void 0,
|
|
5629
5651
|
() => [s.get(n), s, n]
|
|
5630
5652
|
);
|
|
5631
5653
|
let c = o;
|
|
5632
5654
|
if ((r !== s || a !== n) && (l(), c = s.get(n)), _e(() => {
|
|
5633
|
-
const
|
|
5655
|
+
const f = s.sub(n, () => {
|
|
5634
5656
|
if (i)
|
|
5635
5657
|
try {
|
|
5636
5658
|
const p = s.get(n);
|
|
@@ -5645,10 +5667,10 @@ function dt(n, e) {
|
|
|
5645
5667
|
}
|
|
5646
5668
|
l();
|
|
5647
5669
|
});
|
|
5648
|
-
return l(),
|
|
5670
|
+
return l(), f;
|
|
5649
5671
|
}, [s, n, t, i]), un(c), At(c)) {
|
|
5650
|
-
const
|
|
5651
|
-
return i && Ot(
|
|
5672
|
+
const f = _i(c, () => s.get(n));
|
|
5673
|
+
return i && Ot(f), Ko(f);
|
|
5652
5674
|
}
|
|
5653
5675
|
return c;
|
|
5654
5676
|
}
|
|
@@ -5743,33 +5765,49 @@ const cn = yi(null), lr = ({
|
|
|
5743
5765
|
versionId: i,
|
|
5744
5766
|
widgetVersion: s,
|
|
5745
5767
|
debug: o,
|
|
5746
|
-
vad: r
|
|
5768
|
+
vad: r,
|
|
5769
|
+
clientTools: a,
|
|
5770
|
+
clientToolTimeoutMs: l
|
|
5747
5771
|
}) => {
|
|
5748
|
-
const [
|
|
5772
|
+
const [c, f] = pn(() => new pi({
|
|
5749
5773
|
agentId: e,
|
|
5750
5774
|
environment: t,
|
|
5751
5775
|
versionId: i,
|
|
5752
5776
|
widgetVersion: s,
|
|
5753
5777
|
debug: o,
|
|
5754
|
-
vad: r
|
|
5778
|
+
vad: r,
|
|
5779
|
+
clientTools: a,
|
|
5780
|
+
clientToolTimeoutMs: l
|
|
5755
5781
|
}));
|
|
5756
5782
|
return _e(() => {
|
|
5757
|
-
if (!
|
|
5758
|
-
const
|
|
5783
|
+
if (!c) {
|
|
5784
|
+
const p = new pi({
|
|
5759
5785
|
agentId: e,
|
|
5760
5786
|
environment: t,
|
|
5761
5787
|
versionId: i,
|
|
5762
5788
|
widgetVersion: s,
|
|
5763
5789
|
debug: o,
|
|
5764
|
-
vad: r
|
|
5790
|
+
vad: r,
|
|
5791
|
+
clientTools: a,
|
|
5792
|
+
clientToolTimeoutMs: l
|
|
5765
5793
|
});
|
|
5766
|
-
return
|
|
5767
|
-
|
|
5794
|
+
return f(p), () => {
|
|
5795
|
+
p.disconnect();
|
|
5768
5796
|
};
|
|
5769
5797
|
}
|
|
5770
|
-
}, [
|
|
5771
|
-
|
|
5772
|
-
|
|
5798
|
+
}, [
|
|
5799
|
+
e,
|
|
5800
|
+
c,
|
|
5801
|
+
o,
|
|
5802
|
+
t,
|
|
5803
|
+
i,
|
|
5804
|
+
s,
|
|
5805
|
+
r,
|
|
5806
|
+
a,
|
|
5807
|
+
l
|
|
5808
|
+
]), _e(() => {
|
|
5809
|
+
c?.connect();
|
|
5810
|
+
}, [c]), /* @__PURE__ */ Oe.jsxs(cn.Provider, { value: c, children: [
|
|
5773
5811
|
/* @__PURE__ */ Oe.jsx(zo, {}),
|
|
5774
5812
|
/* @__PURE__ */ Oe.jsx(Xo, {}),
|
|
5775
5813
|
/* @__PURE__ */ Oe.jsx(er, {}),
|