@d-id/client-sdk 1.1.11-staging.42 → 1.1.11-staging.44
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/{index-n99Xwccj.js → index-BHt2AhLb.js} +337 -331
- package/dist/index.js +1 -1
- package/dist/index.umd.cjs +5 -5
- package/dist/{livekit-manager-BNSy5Ehr.js → livekit-manager-DZ_BAT5P.js} +3 -2
- package/dist/src/services/streaming-manager/common.d.ts +4 -0
- package/dist/src/types/entities/agents/manager.d.ts +4 -0
- package/dist/src/types/stream/rtc.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
class
|
|
1
|
+
var ke = Object.defineProperty;
|
|
2
|
+
var De = (e, t, n) => t in e ? ke(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var Z = (e, t, n) => De(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
class te extends Error {
|
|
5
5
|
constructor({ kind: n, description: r, error: i }) {
|
|
6
6
|
super(JSON.stringify({ kind: n, description: r }));
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
Z(this, "kind");
|
|
8
|
+
Z(this, "description");
|
|
9
|
+
Z(this, "error");
|
|
10
10
|
this.kind = n, this.description = r, this.error = i;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
class
|
|
13
|
+
class Ce extends te {
|
|
14
14
|
constructor(t, n) {
|
|
15
15
|
super({
|
|
16
16
|
kind: "ChatCreationFailed",
|
|
@@ -18,25 +18,25 @@ class De extends ee {
|
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
class
|
|
21
|
+
class Re extends te {
|
|
22
22
|
constructor(t) {
|
|
23
23
|
super({ kind: "ChatModeDowngraded", description: `Chat mode downgraded to ${t}` });
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
class H extends
|
|
26
|
+
class H extends te {
|
|
27
27
|
constructor(n, r) {
|
|
28
28
|
super({ kind: "ValidationError", description: n });
|
|
29
|
-
|
|
29
|
+
Z(this, "key");
|
|
30
30
|
this.key = r;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
class
|
|
33
|
+
class Se extends te {
|
|
34
34
|
constructor(t) {
|
|
35
35
|
super({ kind: "WSError", description: t });
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
var
|
|
39
|
-
const
|
|
38
|
+
var Ie = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(Ie || {}), Ee = /* @__PURE__ */ ((e) => (e.TRIAL = "deid-trial", e.PRO = "deid-pro", e.ENTERPRISE = "deid-enterprise", e.LITE = "deid-lite", e.ADVANCED = "deid-advanced", e.BUILD = "deid-api-build", e.LAUNCH = "deid-api-launch", e.SCALE = "deid-api-scale", e))(Ee || {}), Me = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(Me || {}), _e = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(_e || {}), E = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e.Off = "Off", e))(E || {}), q = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Complete = "done", e))(q || {}), Te = /* @__PURE__ */ ((e) => (e.KnowledgeProcessing = "knowledge/processing", e.KnowledgeIndexing = "knowledge/indexing", e.KnowledgeFailed = "knowledge/error", e.KnowledgeDone = "knowledge/done", e))(Te || {}), je = /* @__PURE__ */ ((e) => (e.Knowledge = "knowledge", e.Document = "document", e.Record = "record", e))(je || {}), Ae = /* @__PURE__ */ ((e) => (e.Pdf = "pdf", e.Text = "text", e.Html = "html", e.Word = "word", e.Json = "json", e.Markdown = "markdown", e.Csv = "csv", e.Excel = "excel", e.Powerpoint = "powerpoint", e.Archive = "archive", e.Image = "image", e.Audio = "audio", e.Video = "video", e))(Ae || {}), de = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e.Expressive = "expressive", e))(de || {});
|
|
39
|
+
const jt = (e) => {
|
|
40
40
|
switch (e) {
|
|
41
41
|
case "clip":
|
|
42
42
|
return "clip";
|
|
@@ -46,12 +46,12 @@ const Tt = (e) => {
|
|
|
46
46
|
throw new Error(`Unknown video type: ${e}`);
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
var w = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(w || {}),
|
|
50
|
-
const
|
|
49
|
+
var w = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(w || {}), G = /* @__PURE__ */ ((e) => (e.Strong = "STRONG", e.Weak = "WEAK", e.Unknown = "UNKNOWN", e))(G || {}), O = /* @__PURE__ */ ((e) => (e.Idle = "IDLE", e.Talking = "TALKING", e))(O || {}), P = /* @__PURE__ */ ((e) => (e.ChatAnswer = "chat/answer", e.ChatPartial = "chat/partial", e.StreamDone = "stream/done", e.StreamStarted = "stream/started", e.StreamFailed = "stream/error", e.StreamReady = "stream/ready", e.StreamCreated = "stream/created", e.StreamInterrupt = "stream/interrupt", e.StreamVideoCreated = "stream-video/started", e.StreamVideoDone = "stream-video/done", e.StreamVideoError = "stream-video/error", e.StreamVideoRejected = "stream-video/rejected", e))(P || {}), R = /* @__PURE__ */ ((e) => (e.New = "new", e.Fail = "fail", e.Connected = "connected", e.Connecting = "connecting", e.Closed = "closed", e.Completed = "completed", e.Disconnected = "disconnected", e))(R || {}), J = /* @__PURE__ */ ((e) => (e.Legacy = "legacy", e.Fluent = "fluent", e))(J || {}), be = /* @__PURE__ */ ((e) => (e.Livekit = "livekit", e))(be || {}), Pe = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.Microsoft = "microsoft", e.Afflorithmics = "afflorithmics", e.Elevenlabs = "elevenlabs", e))(Pe || {}), Le = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e))(Le || {});
|
|
50
|
+
const Be = 45 * 1e3, $e = "X-Playground-Chat", ee = "https://api.d-id.com", xe = "wss://notifications.d-id.com", ze = "79f81a83a67430be2bc0fd61042b8faa", le = (e) => new Promise((t) => setTimeout(t, e)), V = (e = 16) => {
|
|
51
51
|
const t = new Uint8Array(e);
|
|
52
52
|
return window.crypto.getRandomValues(t), Array.from(t, (n) => n.toString(16).padStart(2, "0")).join("").slice(0, 13);
|
|
53
|
-
},
|
|
54
|
-
function
|
|
53
|
+
}, Fe = (e) => [E.TextOnly, E.Playground, E.Maintenance].includes(e), ue = (e) => e && [E.DirectPlayback, E.Off].includes(e);
|
|
54
|
+
function Ne(e, t) {
|
|
55
55
|
let n;
|
|
56
56
|
return {
|
|
57
57
|
promise: new Promise((i, o) => {
|
|
@@ -60,7 +60,7 @@ function Fe(e, t) {
|
|
|
60
60
|
clear: () => clearTimeout(n)
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
-
async function
|
|
63
|
+
async function ne(e, t) {
|
|
64
64
|
const n = {
|
|
65
65
|
limit: (t == null ? void 0 : t.limit) ?? 3,
|
|
66
66
|
delayMs: (t == null ? void 0 : t.delayMs) ?? 0,
|
|
@@ -75,16 +75,16 @@ async function re(e, t) {
|
|
|
75
75
|
try {
|
|
76
76
|
if (!n.timeout)
|
|
77
77
|
return await e();
|
|
78
|
-
const { promise: o, clear: c } =
|
|
78
|
+
const { promise: o, clear: c } = Ne(n.timeout, n.timeoutErrorMessage), a = e().finally(c);
|
|
79
79
|
return await Promise.race([a, o]);
|
|
80
80
|
} catch (o) {
|
|
81
81
|
if (r = o, !n.shouldRetryFn(o) || i >= n.limit)
|
|
82
82
|
throw o;
|
|
83
|
-
await
|
|
83
|
+
await le(n.delayMs), n.onRetry(o);
|
|
84
84
|
}
|
|
85
85
|
throw r;
|
|
86
86
|
}
|
|
87
|
-
function
|
|
87
|
+
function fe() {
|
|
88
88
|
let e = window.localStorage.getItem("did_external_key_id");
|
|
89
89
|
if (!e) {
|
|
90
90
|
let t = V();
|
|
@@ -92,30 +92,30 @@ function ue() {
|
|
|
92
92
|
}
|
|
93
93
|
return e;
|
|
94
94
|
}
|
|
95
|
-
let
|
|
96
|
-
function
|
|
95
|
+
let Je = V();
|
|
96
|
+
function me(e) {
|
|
97
97
|
if (e.type === "bearer")
|
|
98
98
|
return `Bearer ${e.token}`;
|
|
99
99
|
if (e.type === "basic")
|
|
100
100
|
return `Basic ${btoa(`${e.username}:${e.password}`)}`;
|
|
101
101
|
if (e.type === "key")
|
|
102
|
-
return `Client-Key ${e.clientKey}.${
|
|
102
|
+
return `Client-Key ${e.clientKey}.${fe()}_${Je}`;
|
|
103
103
|
throw new Error(`Unknown auth type: ${e}`);
|
|
104
104
|
}
|
|
105
|
-
const
|
|
105
|
+
const We = (e) => ne(e, {
|
|
106
106
|
limit: 3,
|
|
107
107
|
delayMs: 1e3,
|
|
108
108
|
timeout: 0,
|
|
109
109
|
shouldRetryFn: (t) => t.status === 429
|
|
110
110
|
});
|
|
111
|
-
function
|
|
111
|
+
function ge(e, t = ee, n) {
|
|
112
112
|
const r = async (i, o) => {
|
|
113
|
-
const { skipErrorHandler: c, ...a } = o || {}, s = await
|
|
113
|
+
const { skipErrorHandler: c, ...a } = o || {}, s = await We(
|
|
114
114
|
() => fetch(t + (i != null && i.startsWith("/") ? i : `/${i}`), {
|
|
115
115
|
...a,
|
|
116
116
|
headers: {
|
|
117
117
|
...a.headers,
|
|
118
|
-
Authorization:
|
|
118
|
+
Authorization: me(e),
|
|
119
119
|
"Content-Type": "application/json"
|
|
120
120
|
}
|
|
121
121
|
})
|
|
@@ -142,8 +142,8 @@ function me(e, t = G, n) {
|
|
|
142
142
|
}
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
|
-
function
|
|
146
|
-
const r =
|
|
145
|
+
function he(e, t = ee, n) {
|
|
146
|
+
const r = ge(e, `${t}/agents`, n);
|
|
147
147
|
return {
|
|
148
148
|
create(i, o) {
|
|
149
149
|
return r.post("/", i, o);
|
|
@@ -180,8 +180,8 @@ function ge(e, t = G, n) {
|
|
|
180
180
|
}
|
|
181
181
|
};
|
|
182
182
|
}
|
|
183
|
-
const
|
|
184
|
-
function
|
|
183
|
+
const we = (e) => e.type === "clip" && e.presenter_id.startsWith("v2_") ? "clip_v2" : e.type;
|
|
184
|
+
function Ke(e) {
|
|
185
185
|
var i, o, c, a;
|
|
186
186
|
const t = () => /Mobi|Android/i.test(navigator.userAgent) ? "Mobile" : "Desktop", n = () => {
|
|
187
187
|
const s = navigator.platform;
|
|
@@ -192,18 +192,18 @@ function We(e) {
|
|
|
192
192
|
isMobile: `${t() == "Mobile"}`,
|
|
193
193
|
browser: navigator.userAgent,
|
|
194
194
|
origin: window.location.origin,
|
|
195
|
-
agentType:
|
|
195
|
+
agentType: we(r),
|
|
196
196
|
agentVoice: {
|
|
197
197
|
voiceId: (o = (i = e.presenter) == null ? void 0 : i.voice) == null ? void 0 : o.voice_id,
|
|
198
198
|
provider: (a = (c = e.presenter) == null ? void 0 : c.voice) == null ? void 0 : a.type
|
|
199
199
|
}
|
|
200
200
|
};
|
|
201
201
|
}
|
|
202
|
-
function
|
|
202
|
+
function Ue(e) {
|
|
203
203
|
var n, r, i, o, c, a;
|
|
204
204
|
const t = (n = e.llm) == null ? void 0 : n.prompt_customization;
|
|
205
205
|
return {
|
|
206
|
-
agentType:
|
|
206
|
+
agentType: we(e.presenter),
|
|
207
207
|
owner_id: e.owner_id ?? "",
|
|
208
208
|
promptVersion: (r = e.llm) == null ? void 0 : r.prompt_version,
|
|
209
209
|
behavior: {
|
|
@@ -222,8 +222,8 @@ function Ke(e) {
|
|
|
222
222
|
...e.access === "public" ? { from: "agent-template" } : {}
|
|
223
223
|
};
|
|
224
224
|
}
|
|
225
|
-
const
|
|
226
|
-
function
|
|
225
|
+
const He = (e) => e.reduce((t, n) => t + n, 0), se = (e) => He(e) / e.length;
|
|
226
|
+
function qe(e, t, n) {
|
|
227
227
|
var s, d, l;
|
|
228
228
|
const { event: r, ...i } = e, { template: o } = (t == null ? void 0 : t.llm) || {}, { language: c } = ((s = t == null ? void 0 : t.presenter) == null ? void 0 : s.voice) || {};
|
|
229
229
|
return {
|
|
@@ -234,13 +234,13 @@ function He(e, t, n) {
|
|
|
234
234
|
...n
|
|
235
235
|
};
|
|
236
236
|
}
|
|
237
|
-
let
|
|
238
|
-
const
|
|
239
|
-
function
|
|
237
|
+
let re = {};
|
|
238
|
+
const Ve = "https://api-js.mixpanel.com/track/?verbose=1&ip=1";
|
|
239
|
+
function Oe(e) {
|
|
240
240
|
const t = window != null && window.hasOwnProperty("DID_AGENTS_API") ? "agents-ui" : "agents-sdk";
|
|
241
241
|
return {
|
|
242
242
|
token: e.token || "testKey",
|
|
243
|
-
distinct_id: e.distinctId ||
|
|
243
|
+
distinct_id: e.distinctId || fe(),
|
|
244
244
|
agentId: e.agentId,
|
|
245
245
|
additionalProperties: {
|
|
246
246
|
id: e.distinctId,
|
|
@@ -281,14 +281,14 @@ function Ve(e) {
|
|
|
281
281
|
})
|
|
282
282
|
};
|
|
283
283
|
try {
|
|
284
|
-
return await fetch(
|
|
284
|
+
return await fetch(Ve, c).then((a) => a.json());
|
|
285
285
|
} catch (a) {
|
|
286
286
|
return console.error(a);
|
|
287
287
|
}
|
|
288
288
|
},
|
|
289
289
|
linkTrack(n, r, i, o) {
|
|
290
|
-
|
|
291
|
-
const c =
|
|
290
|
+
re[n] || (re[n] = { events: {}, resolvedDependencies: [] }), o.includes(i) || o.push(i);
|
|
291
|
+
const c = re[n];
|
|
292
292
|
if (c.events[i] = { props: r }, c.resolvedDependencies.push(i), o.every(
|
|
293
293
|
(s) => c.resolvedDependencies.includes(s)
|
|
294
294
|
)) {
|
|
@@ -302,7 +302,7 @@ function Ve(e) {
|
|
|
302
302
|
}
|
|
303
303
|
};
|
|
304
304
|
}
|
|
305
|
-
function
|
|
305
|
+
function pe() {
|
|
306
306
|
let e = 0;
|
|
307
307
|
return {
|
|
308
308
|
reset: () => e = 0,
|
|
@@ -310,13 +310,13 @@ function we() {
|
|
|
310
310
|
get: (t = !1) => t ? Date.now() - e : e
|
|
311
311
|
};
|
|
312
312
|
}
|
|
313
|
-
const
|
|
314
|
-
function
|
|
315
|
-
return e === E.Playground ? { headers: { [
|
|
313
|
+
const $ = pe(), ae = pe();
|
|
314
|
+
function ye(e) {
|
|
315
|
+
return e === E.Playground ? { headers: { [$e]: "true" } } : {};
|
|
316
316
|
}
|
|
317
|
-
async function
|
|
317
|
+
async function ve(e, t, n, r, i = !1, o) {
|
|
318
318
|
try {
|
|
319
|
-
return !o && !
|
|
319
|
+
return !o && !ue(r) && (o = await t.newChat(e.id, { persist: i }, ye(r)), n.track("agent-chat", {
|
|
320
320
|
event: "created",
|
|
321
321
|
chatId: o.id,
|
|
322
322
|
mode: r
|
|
@@ -332,20 +332,20 @@ async function ye(e, t, n, r, i = !1, o) {
|
|
|
332
332
|
throw new Error("Cannot create new chat");
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
|
-
function
|
|
335
|
+
function Xe(e) {
|
|
336
336
|
return e && e.length > 0 ? e : [];
|
|
337
337
|
}
|
|
338
|
-
function
|
|
338
|
+
function Ye(e, t, n) {
|
|
339
339
|
if (!e)
|
|
340
340
|
throw new Error("Please connect to the agent first");
|
|
341
341
|
if (!e.interruptAvailable)
|
|
342
342
|
throw new Error("Interrupt is not enabled for this stream");
|
|
343
|
-
if (t !==
|
|
343
|
+
if (t !== J.Fluent)
|
|
344
344
|
throw new Error("Interrupt only available for Fluent streams");
|
|
345
345
|
if (!n)
|
|
346
346
|
throw new Error("No active video to interrupt");
|
|
347
347
|
}
|
|
348
|
-
async function
|
|
348
|
+
async function Qe(e, t) {
|
|
349
349
|
const n = {
|
|
350
350
|
type: P.StreamInterrupt,
|
|
351
351
|
videoId: t,
|
|
@@ -353,37 +353,37 @@ async function Ye(e, t) {
|
|
|
353
353
|
};
|
|
354
354
|
e.sendDataChannelMessage(JSON.stringify(n));
|
|
355
355
|
}
|
|
356
|
-
function
|
|
356
|
+
function Ze(e) {
|
|
357
357
|
return new Promise((t, n) => {
|
|
358
|
-
const { callbacks: r, host: i, auth: o } = e, { onMessage: c = null, onOpen: a = null, onClose: s = null, onError: d = null } = r || {}, l = new WebSocket(`${i}?authorization=${
|
|
359
|
-
l.onmessage = c, l.onclose = s, l.onerror = (
|
|
360
|
-
console.error(
|
|
361
|
-
}, l.onopen = (
|
|
362
|
-
a == null || a(
|
|
358
|
+
const { callbacks: r, host: i, auth: o } = e, { onMessage: c = null, onOpen: a = null, onClose: s = null, onError: d = null } = r || {}, l = new WebSocket(`${i}?authorization=${me(o)}`);
|
|
359
|
+
l.onmessage = c, l.onclose = s, l.onerror = (y) => {
|
|
360
|
+
console.error(y), d == null || d("Websocket failed to connect", y), n(y);
|
|
361
|
+
}, l.onopen = (y) => {
|
|
362
|
+
a == null || a(y), t(l);
|
|
363
363
|
};
|
|
364
364
|
});
|
|
365
365
|
}
|
|
366
|
-
async function
|
|
366
|
+
async function Ge(e) {
|
|
367
367
|
const { retries: t = 1 } = e;
|
|
368
368
|
let n = null;
|
|
369
369
|
for (let r = 0; (n == null ? void 0 : n.readyState) !== WebSocket.OPEN; r++)
|
|
370
370
|
try {
|
|
371
|
-
n = await
|
|
371
|
+
n = await Ze(e);
|
|
372
372
|
} catch (i) {
|
|
373
373
|
if (r === t)
|
|
374
374
|
throw i;
|
|
375
|
-
await
|
|
375
|
+
await le(r * 500);
|
|
376
376
|
}
|
|
377
377
|
return n;
|
|
378
378
|
}
|
|
379
|
-
async function
|
|
380
|
-
const r = n != null && n.onMessage ? [n.onMessage] : [], i = await
|
|
379
|
+
async function et(e, t, n) {
|
|
380
|
+
const r = n != null && n.onMessage ? [n.onMessage] : [], i = await Ge({
|
|
381
381
|
auth: e,
|
|
382
382
|
host: t,
|
|
383
383
|
callbacks: {
|
|
384
384
|
onError: (o) => {
|
|
385
385
|
var c;
|
|
386
|
-
return (c = n.onError) == null ? void 0 : c.call(n, new
|
|
386
|
+
return (c = n.onError) == null ? void 0 : c.call(n, new Se(o));
|
|
387
387
|
},
|
|
388
388
|
onMessage(o) {
|
|
389
389
|
const c = JSON.parse(o.data);
|
|
@@ -397,7 +397,7 @@ async function Ge(e, t, n) {
|
|
|
397
397
|
subscribeToEvents: (o) => r.push(o)
|
|
398
398
|
};
|
|
399
399
|
}
|
|
400
|
-
function
|
|
400
|
+
function tt(e) {
|
|
401
401
|
if (e.answer !== void 0)
|
|
402
402
|
return e.answer;
|
|
403
403
|
let t = 0, n = "";
|
|
@@ -405,41 +405,41 @@ function et(e) {
|
|
|
405
405
|
n += e[t++];
|
|
406
406
|
return n;
|
|
407
407
|
}
|
|
408
|
-
function
|
|
408
|
+
function rt(e, t, n, r, i) {
|
|
409
409
|
const o = r.messages[r.messages.length - 1];
|
|
410
410
|
if (!(e === q.Partial || e === q.Answer) || (o == null ? void 0 : o.role) !== "assistant")
|
|
411
411
|
return;
|
|
412
412
|
const { content: c, sequence: a } = t;
|
|
413
413
|
e === q.Partial ? n[a] = c : n.answer = c;
|
|
414
|
-
const s =
|
|
414
|
+
const s = tt(n);
|
|
415
415
|
(o.content !== s || e === q.Answer) && (o.content = s, i == null || i([...r.messages], e));
|
|
416
416
|
}
|
|
417
|
-
function
|
|
417
|
+
function nt(e, t, n, r, i) {
|
|
418
418
|
let o = {};
|
|
419
419
|
return {
|
|
420
420
|
clearQueue: () => o = {},
|
|
421
421
|
onMessage: (c, a) => {
|
|
422
422
|
var s, d;
|
|
423
423
|
if ("content" in a)
|
|
424
|
-
|
|
424
|
+
rt(c, a, o, t, n.callbacks.onNewMessage), c === q.Answer && e.track("agent-message-received", {
|
|
425
425
|
messages: t.messages.length,
|
|
426
426
|
mode: t.chatMode
|
|
427
427
|
});
|
|
428
428
|
else {
|
|
429
|
-
const l = P,
|
|
429
|
+
const l = P, y = [l.StreamVideoDone, l.StreamVideoError, l.StreamVideoRejected], M = [l.StreamFailed, l.StreamVideoError, l.StreamVideoRejected], j = qe(a, r, { mode: t.chatMode });
|
|
430
430
|
if (c = c, c === l.StreamVideoCreated)
|
|
431
|
-
e.linkTrack("agent-video",
|
|
432
|
-
else if (
|
|
433
|
-
const
|
|
434
|
-
M.includes(c) ? e.track("agent-video", { ...
|
|
431
|
+
e.linkTrack("agent-video", j, l.StreamVideoCreated, ["start"]);
|
|
432
|
+
else if (y.includes(c)) {
|
|
433
|
+
const b = c.split("/")[1];
|
|
434
|
+
M.includes(c) ? e.track("agent-video", { ...j, event: b }) : e.linkTrack("agent-video", { ...j, event: b }, c, ["done"]);
|
|
435
435
|
}
|
|
436
436
|
M.includes(c) && ((d = (s = n.callbacks).onError) == null || d.call(s, new Error(`Stream failed with event ${c}`), { data: a })), a.event === l.StreamDone && i();
|
|
437
437
|
}
|
|
438
438
|
}
|
|
439
439
|
};
|
|
440
440
|
}
|
|
441
|
-
function
|
|
442
|
-
const i =
|
|
441
|
+
function at(e, t, n, r) {
|
|
442
|
+
const i = ge(e, `${t}/agents/${n}`, r);
|
|
443
443
|
return {
|
|
444
444
|
createStream(o) {
|
|
445
445
|
return i.post("/streams", o);
|
|
@@ -467,8 +467,8 @@ function nt(e, t, n, r) {
|
|
|
467
467
|
}
|
|
468
468
|
};
|
|
469
469
|
}
|
|
470
|
-
const
|
|
471
|
-
function
|
|
470
|
+
const it = (e, t) => (n, r) => e && console.log(`[${t}] ${n}`, r ?? "");
|
|
471
|
+
function st(e, t, n) {
|
|
472
472
|
const r = (t.timestamp - e.timestamp) / 1e3;
|
|
473
473
|
return {
|
|
474
474
|
duration: r,
|
|
@@ -488,7 +488,7 @@ function it(e, t, n) {
|
|
|
488
488
|
lowFpsCount: n
|
|
489
489
|
};
|
|
490
490
|
}
|
|
491
|
-
function
|
|
491
|
+
function ot(e) {
|
|
492
492
|
return e.filter(
|
|
493
493
|
(t) => t.freezeCount > 0 || t.framesPerSecond < 21 || t.framesDropped > 0 || t.packetsLost > 0
|
|
494
494
|
).map((t) => {
|
|
@@ -499,7 +499,7 @@ function st(e) {
|
|
|
499
499
|
};
|
|
500
500
|
});
|
|
501
501
|
}
|
|
502
|
-
function
|
|
502
|
+
function ct(e) {
|
|
503
503
|
let t = "", n = 0;
|
|
504
504
|
for (const r of e.values())
|
|
505
505
|
if (r && r.type === "codec" && r.mimeType.startsWith("video") && (t = r.mimeType.split("/")[1]), r && r.type === "candidate-pair" && (n = r.currentRoundTripTime), r && r.type === "inbound-rtp" && r.kind === "video")
|
|
@@ -524,7 +524,7 @@ function ot(e) {
|
|
|
524
524
|
};
|
|
525
525
|
return {};
|
|
526
526
|
}
|
|
527
|
-
function
|
|
527
|
+
function dt(e, t, n) {
|
|
528
528
|
const r = e.map((s, d) => d === 0 ? n ? {
|
|
529
529
|
timestamp: s.timestamp,
|
|
530
530
|
duration: 0,
|
|
@@ -576,32 +576,32 @@ function ct(e, t, n) {
|
|
|
576
576
|
framesPerSecond: s.framesPerSecond,
|
|
577
577
|
freezeCount: s.freezeCount - e[d - 1].freezeCount,
|
|
578
578
|
freezeDuration: s.freezeDuration - e[d - 1].freezeDuration
|
|
579
|
-
}), i =
|
|
579
|
+
}), i = ot(r), o = i.reduce((s, d) => s + (d.causes.includes("low fps") ? 1 : 0), 0), c = r.filter((s) => !!s.avgJitterDelayInInterval).map((s) => s.avgJitterDelayInInterval), a = r.filter((s) => !!s.rtt).map((s) => s.rtt);
|
|
580
580
|
return {
|
|
581
581
|
webRTCStats: {
|
|
582
582
|
anomalies: i,
|
|
583
583
|
minRtt: Math.min(...a),
|
|
584
|
-
avgRtt:
|
|
584
|
+
avgRtt: se(a),
|
|
585
585
|
maxRtt: Math.max(...a),
|
|
586
|
-
aggregateReport:
|
|
586
|
+
aggregateReport: st(e[0], e[e.length - 1], o),
|
|
587
587
|
minJitterDelayInInterval: Math.min(...c),
|
|
588
588
|
maxJitterDelayInInterval: Math.max(...c),
|
|
589
|
-
avgJitterDelayInInterval:
|
|
589
|
+
avgJitterDelayInInterval: se(c)
|
|
590
590
|
},
|
|
591
591
|
codec: e[0].codec,
|
|
592
592
|
resolution: `${e[0].frameWidth}x${e[0].frameHeight}`
|
|
593
593
|
};
|
|
594
594
|
}
|
|
595
|
-
const
|
|
596
|
-
function
|
|
595
|
+
const ie = 100, lt = Math.max(Math.ceil(400 / ie), 1), ut = 0.25, ft = 0.28;
|
|
596
|
+
function mt() {
|
|
597
597
|
let e = 0, t, n, r = 0;
|
|
598
598
|
return (i) => {
|
|
599
599
|
for (const o of i.values())
|
|
600
600
|
if (o && o.type === "inbound-rtp" && o.kind === "video") {
|
|
601
601
|
const c = o.jitterBufferDelay, a = o.jitterBufferEmittedCount;
|
|
602
602
|
if (n && a > n) {
|
|
603
|
-
const l = c - t,
|
|
604
|
-
r = l /
|
|
603
|
+
const l = c - t, y = a - n;
|
|
604
|
+
r = l / y;
|
|
605
605
|
}
|
|
606
606
|
t = c, n = a;
|
|
607
607
|
const s = o.framesDecoded, d = s - e > 0;
|
|
@@ -610,41 +610,41 @@ function ft() {
|
|
|
610
610
|
return { isReceiving: !1, avgJitterDelayInInterval: r };
|
|
611
611
|
};
|
|
612
612
|
}
|
|
613
|
-
function
|
|
614
|
-
let c = [], a, s = 0, d = !1, l =
|
|
615
|
-
const
|
|
613
|
+
function gt(e, t, n, r, i, o = !1) {
|
|
614
|
+
let c = [], a, s = 0, d = !1, l = G.Unknown, y = G.Unknown, M = 0, j = 0;
|
|
615
|
+
const b = mt();
|
|
616
616
|
return setInterval(async () => {
|
|
617
|
-
const
|
|
617
|
+
const z = await e.getStats(), { isReceiving: K, avgJitterDelayInInterval: W, freezeCount: C } = b(z), U = ct(z);
|
|
618
618
|
if (K)
|
|
619
|
-
s = 0, M =
|
|
620
|
-
else if (d && (s++, s >=
|
|
621
|
-
const u =
|
|
622
|
-
r == null || r(w.Stop, u), t() || n(),
|
|
619
|
+
s = 0, M = C - j, y = W < ut ? G.Strong : W > ft && M > 1 ? G.Weak : l, y !== l && (i == null || i(y), l = y, j += M, M = 0), d || (r == null || r(w.Start), a = c[c.length - 1], c = [], d = !0), c.push(U);
|
|
620
|
+
else if (d && (s++, s >= lt)) {
|
|
621
|
+
const u = dt(c, ie, a);
|
|
622
|
+
r == null || r(w.Stop, u), t() || n(), j = C, d = !1;
|
|
623
623
|
}
|
|
624
|
-
},
|
|
624
|
+
}, ie);
|
|
625
625
|
}
|
|
626
|
-
const
|
|
627
|
-
function
|
|
626
|
+
const ht = (window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection).bind(window);
|
|
627
|
+
function oe(e) {
|
|
628
628
|
switch (e) {
|
|
629
629
|
case "connected":
|
|
630
|
-
return
|
|
630
|
+
return R.Connected;
|
|
631
631
|
case "checking":
|
|
632
|
-
return
|
|
632
|
+
return R.Connecting;
|
|
633
633
|
case "failed":
|
|
634
|
-
return
|
|
634
|
+
return R.Fail;
|
|
635
635
|
case "new":
|
|
636
|
-
return
|
|
636
|
+
return R.New;
|
|
637
637
|
case "closed":
|
|
638
|
-
return
|
|
638
|
+
return R.Closed;
|
|
639
639
|
case "disconnected":
|
|
640
|
-
return
|
|
640
|
+
return R.Disconnected;
|
|
641
641
|
case "completed":
|
|
642
|
-
return
|
|
642
|
+
return R.Completed;
|
|
643
643
|
default:
|
|
644
|
-
return
|
|
644
|
+
return R.New;
|
|
645
645
|
}
|
|
646
646
|
}
|
|
647
|
-
const
|
|
647
|
+
const wt = (e) => (t) => {
|
|
648
648
|
const [n, r = ""] = t.split(/:(.+)/);
|
|
649
649
|
try {
|
|
650
650
|
const i = JSON.parse(r);
|
|
@@ -653,7 +653,7 @@ const ht = (e) => (t) => {
|
|
|
653
653
|
return e("Failed to parse data channel message, returning data as string", { subject: n, rawData: r, error: i }), { subject: n, data: r };
|
|
654
654
|
}
|
|
655
655
|
};
|
|
656
|
-
function
|
|
656
|
+
function pt({
|
|
657
657
|
statsSignal: e,
|
|
658
658
|
dataChannelSignal: t,
|
|
659
659
|
onVideoStateChange: n,
|
|
@@ -661,7 +661,7 @@ function wt({
|
|
|
661
661
|
}) {
|
|
662
662
|
e === w.Start && t === w.Start ? n == null || n(w.Start) : e === w.Stop && t === w.Stop && (n == null || n(w.Stop, r));
|
|
663
663
|
}
|
|
664
|
-
function
|
|
664
|
+
function yt({
|
|
665
665
|
statsSignal: e,
|
|
666
666
|
dataChannelSignal: t,
|
|
667
667
|
onVideoStateChange: n,
|
|
@@ -670,7 +670,7 @@ function pt({
|
|
|
670
670
|
}) {
|
|
671
671
|
e === w.Start ? n == null || n(w.Start) : e === w.Stop && (n == null || n(w.Stop, i)), t === w.Start ? r == null || r(O.Talking) : t === w.Stop && (r == null || r(O.Idle));
|
|
672
672
|
}
|
|
673
|
-
function
|
|
673
|
+
function ce({
|
|
674
674
|
statsSignal: e,
|
|
675
675
|
dataChannelSignal: t,
|
|
676
676
|
onVideoStateChange: n,
|
|
@@ -678,7 +678,7 @@ function oe({
|
|
|
678
678
|
streamType: i,
|
|
679
679
|
report: o
|
|
680
680
|
}) {
|
|
681
|
-
i ===
|
|
681
|
+
i === J.Legacy ? pt({ statsSignal: e, dataChannelSignal: t, onVideoStateChange: n, report: o }) : i === J.Fluent && yt({
|
|
682
682
|
statsSignal: e,
|
|
683
683
|
dataChannelSignal: t,
|
|
684
684
|
onVideoStateChange: n,
|
|
@@ -686,157 +686,158 @@ function oe({
|
|
|
686
686
|
report: o
|
|
687
687
|
});
|
|
688
688
|
}
|
|
689
|
-
async function
|
|
690
|
-
var
|
|
691
|
-
const a =
|
|
692
|
-
let d = !1, l = !1,
|
|
693
|
-
const { startConnection:
|
|
689
|
+
async function vt(e, t, { debug: n = !1, callbacks: r, auth: i, baseURL: o = ee, analytics: c }) {
|
|
690
|
+
var Y;
|
|
691
|
+
const a = it(n, "WebRTCStreamingManager"), s = wt(a);
|
|
692
|
+
let d = !1, l = !1, y = w.Stop, M = w.Stop;
|
|
693
|
+
const { startConnection: j, sendStreamRequest: b, close: z, createStream: K, addIceCandidate: W } = at(
|
|
694
694
|
i,
|
|
695
695
|
o,
|
|
696
696
|
e,
|
|
697
697
|
r.onError
|
|
698
698
|
), {
|
|
699
|
-
id:
|
|
699
|
+
id: C,
|
|
700
700
|
offer: U,
|
|
701
701
|
ice_servers: u,
|
|
702
702
|
session_id: h,
|
|
703
703
|
fluent: p,
|
|
704
|
-
interrupt_enabled: _
|
|
704
|
+
interrupt_enabled: _,
|
|
705
|
+
triggers_enabled: v
|
|
705
706
|
} = await K(t);
|
|
706
|
-
(
|
|
707
|
-
const
|
|
707
|
+
(Y = r.onStreamCreated) == null || Y.call(r, { stream_id: C, session_id: h, agent_id: e });
|
|
708
|
+
const f = new ht({ iceServers: u }), S = f.createDataChannel("JanusDataChannel");
|
|
708
709
|
if (!h)
|
|
709
710
|
throw new Error("Could not create session_id");
|
|
710
|
-
const
|
|
711
|
+
const T = p ? J.Fluent : J.Legacy;
|
|
711
712
|
c.enrich({
|
|
712
|
-
"stream-type":
|
|
713
|
+
"stream-type": T
|
|
713
714
|
});
|
|
714
|
-
const
|
|
715
|
-
var
|
|
716
|
-
d = !0, l && ((
|
|
717
|
-
},
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
(
|
|
722
|
-
statsSignal: M =
|
|
723
|
-
dataChannelSignal:
|
|
715
|
+
const L = t.stream_warmup && !p, D = () => d, I = () => {
|
|
716
|
+
var m;
|
|
717
|
+
d = !0, l && ((m = r.onConnectionStateChange) == null || m.call(r, R.Connected));
|
|
718
|
+
}, k = gt(
|
|
719
|
+
f,
|
|
720
|
+
D,
|
|
721
|
+
I,
|
|
722
|
+
(m, g) => ce({
|
|
723
|
+
statsSignal: M = m,
|
|
724
|
+
dataChannelSignal: T === J.Legacy ? y : void 0,
|
|
724
725
|
onVideoStateChange: r.onVideoStateChange,
|
|
725
726
|
onAgentActivityStateChange: r.onAgentActivityStateChange,
|
|
726
727
|
report: g,
|
|
727
|
-
streamType:
|
|
728
|
+
streamType: T
|
|
728
729
|
}),
|
|
729
|
-
(
|
|
730
|
+
(m) => {
|
|
730
731
|
var g;
|
|
731
|
-
return (g = r.onConnectivityStateChange) == null ? void 0 : g.call(r,
|
|
732
|
+
return (g = r.onConnectivityStateChange) == null ? void 0 : g.call(r, m);
|
|
732
733
|
},
|
|
733
|
-
|
|
734
|
+
L
|
|
734
735
|
);
|
|
735
|
-
|
|
736
|
+
f.onicecandidate = (m) => {
|
|
736
737
|
var g;
|
|
737
|
-
a("peerConnection.onicecandidate",
|
|
738
|
+
a("peerConnection.onicecandidate", m);
|
|
738
739
|
try {
|
|
739
|
-
|
|
740
|
-
|
|
740
|
+
m.candidate && m.candidate.sdpMid && m.candidate.sdpMLineIndex !== null ? W(
|
|
741
|
+
C,
|
|
741
742
|
{
|
|
742
|
-
candidate:
|
|
743
|
-
sdpMid:
|
|
744
|
-
sdpMLineIndex:
|
|
743
|
+
candidate: m.candidate.candidate,
|
|
744
|
+
sdpMid: m.candidate.sdpMid,
|
|
745
|
+
sdpMLineIndex: m.candidate.sdpMLineIndex
|
|
745
746
|
},
|
|
746
747
|
h
|
|
747
|
-
) :
|
|
748
|
-
} catch (
|
|
749
|
-
(g = r.onError) == null || g.call(r,
|
|
748
|
+
) : W(C, { candidate: null }, h);
|
|
749
|
+
} catch (A) {
|
|
750
|
+
(g = r.onError) == null || g.call(r, A, { streamId: C });
|
|
750
751
|
}
|
|
751
|
-
},
|
|
752
|
-
l = !0, (!
|
|
752
|
+
}, S.onopen = () => {
|
|
753
|
+
l = !0, (!L || d) && I();
|
|
753
754
|
};
|
|
754
|
-
const
|
|
755
|
+
const x = (m) => {
|
|
755
756
|
var g;
|
|
756
|
-
(g = r.onVideoIdChange) == null || g.call(r,
|
|
757
|
+
(g = r.onVideoIdChange) == null || g.call(r, m);
|
|
757
758
|
};
|
|
758
|
-
function
|
|
759
|
-
if (
|
|
760
|
-
const
|
|
761
|
-
|
|
759
|
+
function B(m, g) {
|
|
760
|
+
if (m === P.StreamStarted && typeof g == "object" && "metadata" in g) {
|
|
761
|
+
const A = g.metadata;
|
|
762
|
+
x(A.videoId);
|
|
762
763
|
}
|
|
763
|
-
|
|
764
|
-
statsSignal:
|
|
765
|
-
dataChannelSignal:
|
|
764
|
+
m === P.StreamDone && x(null), y = m === P.StreamStarted ? w.Start : w.Stop, ce({
|
|
765
|
+
statsSignal: T === J.Legacy ? M : void 0,
|
|
766
|
+
dataChannelSignal: y,
|
|
766
767
|
onVideoStateChange: r.onVideoStateChange,
|
|
767
768
|
onAgentActivityStateChange: r.onAgentActivityStateChange,
|
|
768
|
-
streamType:
|
|
769
|
+
streamType: T
|
|
769
770
|
});
|
|
770
771
|
}
|
|
771
|
-
function
|
|
772
|
-
const
|
|
773
|
-
|
|
772
|
+
function F(m, g) {
|
|
773
|
+
const A = typeof g == "string" ? g : g == null ? void 0 : g.metadata;
|
|
774
|
+
A && c.enrich({ streamMetadata: A }), c.track("agent-chat", { event: "ready" });
|
|
774
775
|
}
|
|
775
|
-
const
|
|
776
|
-
[P.StreamStarted]:
|
|
777
|
-
[P.StreamDone]:
|
|
778
|
-
[P.StreamReady]:
|
|
776
|
+
const N = {
|
|
777
|
+
[P.StreamStarted]: B,
|
|
778
|
+
[P.StreamDone]: B,
|
|
779
|
+
[P.StreamReady]: F
|
|
779
780
|
};
|
|
780
|
-
|
|
781
|
-
var
|
|
782
|
-
const { subject: g, data:
|
|
783
|
-
(
|
|
784
|
-
},
|
|
781
|
+
S.onmessage = (m) => {
|
|
782
|
+
var Q;
|
|
783
|
+
const { subject: g, data: A } = s(m.data);
|
|
784
|
+
(Q = N[g]) == null || Q.call(N, g, A);
|
|
785
|
+
}, f.oniceconnectionstatechange = () => {
|
|
785
786
|
var g;
|
|
786
|
-
a("peerConnection.oniceconnectionstatechange => " +
|
|
787
|
-
const
|
|
788
|
-
|
|
789
|
-
},
|
|
787
|
+
a("peerConnection.oniceconnectionstatechange => " + f.iceConnectionState);
|
|
788
|
+
const m = oe(f.iceConnectionState);
|
|
789
|
+
m !== R.Connected && ((g = r.onConnectionStateChange) == null || g.call(r, m));
|
|
790
|
+
}, f.ontrack = (m) => {
|
|
790
791
|
var g;
|
|
791
|
-
a("peerConnection.ontrack",
|
|
792
|
-
}, await
|
|
793
|
-
const
|
|
794
|
-
return a("create answer OK"), await
|
|
792
|
+
a("peerConnection.ontrack", m), (g = r.onSrcObjectReady) == null || g.call(r, m.streams[0]);
|
|
793
|
+
}, await f.setRemoteDescription(U), a("set remote description OK");
|
|
794
|
+
const X = await f.createAnswer();
|
|
795
|
+
return a("create answer OK"), await f.setLocalDescription(X), a("set local description OK"), await j(C, X, h), a("start connection OK"), {
|
|
795
796
|
/**
|
|
796
797
|
* Method to send request to server to get clip or talk depend on you payload
|
|
797
798
|
* @param payload
|
|
798
799
|
*/
|
|
799
|
-
speak(
|
|
800
|
-
return
|
|
800
|
+
speak(m) {
|
|
801
|
+
return b(C, h, m);
|
|
801
802
|
},
|
|
802
803
|
/**
|
|
803
804
|
* Method to close RTC connection
|
|
804
805
|
*/
|
|
805
806
|
async disconnect() {
|
|
806
|
-
var
|
|
807
|
-
if (
|
|
808
|
-
const g =
|
|
809
|
-
if (
|
|
810
|
-
if (g ===
|
|
811
|
-
clearInterval(
|
|
807
|
+
var m;
|
|
808
|
+
if (C) {
|
|
809
|
+
const g = oe(f.iceConnectionState);
|
|
810
|
+
if (f) {
|
|
811
|
+
if (g === R.New) {
|
|
812
|
+
clearInterval(k);
|
|
812
813
|
return;
|
|
813
814
|
}
|
|
814
|
-
|
|
815
|
+
f.close(), f.oniceconnectionstatechange = null, f.onnegotiationneeded = null, f.onicecandidate = null, f.ontrack = null;
|
|
815
816
|
}
|
|
816
817
|
try {
|
|
817
|
-
g ===
|
|
818
|
+
g === R.Connected && await z(C, h).catch((A) => {
|
|
818
819
|
});
|
|
819
|
-
} catch (
|
|
820
|
-
a("Error on close stream connection",
|
|
820
|
+
} catch (A) {
|
|
821
|
+
a("Error on close stream connection", A);
|
|
821
822
|
}
|
|
822
|
-
(
|
|
823
|
+
(m = r.onAgentActivityStateChange) == null || m.call(r, O.Idle), clearInterval(k);
|
|
823
824
|
}
|
|
824
825
|
},
|
|
825
826
|
/**
|
|
826
827
|
* Method to send data channel messages to the server
|
|
827
828
|
*/
|
|
828
|
-
sendDataChannelMessage(
|
|
829
|
-
var g,
|
|
830
|
-
if (!d ||
|
|
829
|
+
sendDataChannelMessage(m) {
|
|
830
|
+
var g, A;
|
|
831
|
+
if (!d || S.readyState !== "open") {
|
|
831
832
|
a("Data channel is not ready for sending messages"), (g = r.onError) == null || g.call(r, new Error("Data channel is not ready for sending messages"), {
|
|
832
|
-
streamId:
|
|
833
|
+
streamId: C
|
|
833
834
|
});
|
|
834
835
|
return;
|
|
835
836
|
}
|
|
836
837
|
try {
|
|
837
|
-
|
|
838
|
-
} catch (
|
|
839
|
-
a("Error sending data channel message",
|
|
838
|
+
S.send(m);
|
|
839
|
+
} catch (Q) {
|
|
840
|
+
a("Error sending data channel message", Q), (A = r.onError) == null || A.call(r, Q, { streamId: C });
|
|
840
841
|
}
|
|
841
842
|
},
|
|
842
843
|
/**
|
|
@@ -846,21 +847,22 @@ async function yt(e, t, { debug: n = !1, callbacks: r, auth: i, baseURL: o = G,
|
|
|
846
847
|
/**
|
|
847
848
|
* Id of current RTC stream
|
|
848
849
|
*/
|
|
849
|
-
streamId:
|
|
850
|
-
streamType:
|
|
851
|
-
interruptAvailable: _ ?? !1
|
|
850
|
+
streamId: C,
|
|
851
|
+
streamType: T,
|
|
852
|
+
interruptAvailable: _ ?? !1,
|
|
853
|
+
triggersAvailable: v ?? !1
|
|
852
854
|
};
|
|
853
855
|
}
|
|
854
|
-
const
|
|
855
|
-
async function
|
|
856
|
+
const kt = (e) => e.presenter.type === de.Expressive;
|
|
857
|
+
async function Dt(e, t, n) {
|
|
856
858
|
const r = e.id;
|
|
857
|
-
if (
|
|
858
|
-
const { createLiveKitStreamingManager: i } = await import("./livekit-manager-
|
|
859
|
+
if (kt(e)) {
|
|
860
|
+
const { createLiveKitStreamingManager: i } = await import("./livekit-manager-DZ_BAT5P.js");
|
|
859
861
|
return i(r, t, n);
|
|
860
862
|
} else
|
|
861
|
-
return
|
|
863
|
+
return vt(r, t, n);
|
|
862
864
|
}
|
|
863
|
-
function
|
|
865
|
+
function Ct(e) {
|
|
864
866
|
const { streamOptions: t } = e ?? {};
|
|
865
867
|
return {
|
|
866
868
|
output_resolution: t == null ? void 0 : t.outputResolution,
|
|
@@ -870,10 +872,10 @@ function Dt(e) {
|
|
|
870
872
|
fluent: t == null ? void 0 : t.fluent
|
|
871
873
|
};
|
|
872
874
|
}
|
|
873
|
-
function Ct(e, t, n, r, i) {
|
|
874
|
-
i === N.Fluent ? Rt(e, t, n, r, i) : It(e, t, n, r, i);
|
|
875
|
-
}
|
|
876
875
|
function Rt(e, t, n, r, i) {
|
|
876
|
+
i === J.Fluent ? St(e, t, n, r, i) : Et(e, t, n, r, i);
|
|
877
|
+
}
|
|
878
|
+
function St(e, t, n, r, i) {
|
|
877
879
|
e === w.Start ? r.track("stream-session", { event: "start", "stream-type": i }) : e === w.Stop && r.track("stream-session", {
|
|
878
880
|
event: "stop",
|
|
879
881
|
is_greenscreen: t.presenter.type === "clip" && t.presenter.is_greenscreen,
|
|
@@ -882,10 +884,10 @@ function Rt(e, t, n, r, i) {
|
|
|
882
884
|
...n
|
|
883
885
|
});
|
|
884
886
|
}
|
|
885
|
-
function
|
|
886
|
-
|
|
887
|
+
function It(e, t, n, r) {
|
|
888
|
+
$.get() <= 0 || (e === w.Start ? n.linkTrack(
|
|
887
889
|
"agent-video",
|
|
888
|
-
{ event: "start", latency:
|
|
890
|
+
{ event: "start", latency: $.get(!0), "stream-type": r },
|
|
889
891
|
"start",
|
|
890
892
|
[P.StreamVideoCreated]
|
|
891
893
|
) : e === w.Stop && n.linkTrack(
|
|
@@ -900,10 +902,10 @@ function St(e, t, n, r) {
|
|
|
900
902
|
[P.StreamVideoDone]
|
|
901
903
|
));
|
|
902
904
|
}
|
|
903
|
-
function
|
|
904
|
-
|
|
905
|
+
function Et(e, t, n, r, i) {
|
|
906
|
+
$.get() <= 0 || (e === w.Start ? r.linkTrack(
|
|
905
907
|
"agent-video",
|
|
906
|
-
{ event: "start", latency:
|
|
908
|
+
{ event: "start", latency: $.get(!0), "stream-type": i },
|
|
907
909
|
"start",
|
|
908
910
|
[P.StreamVideoCreated]
|
|
909
911
|
) : e === w.Stop && r.linkTrack(
|
|
@@ -919,22 +921,22 @@ function It(e, t, n, r, i) {
|
|
|
919
921
|
[P.StreamVideoDone]
|
|
920
922
|
));
|
|
921
923
|
}
|
|
922
|
-
function
|
|
923
|
-
return
|
|
924
|
+
function Mt(e, t, n) {
|
|
925
|
+
return $.reset(), new Promise(async (r, i) => {
|
|
924
926
|
try {
|
|
925
927
|
let o;
|
|
926
|
-
o = await
|
|
928
|
+
o = await Dt(e, Ct(t), {
|
|
927
929
|
...t,
|
|
928
930
|
analytics: n,
|
|
929
931
|
callbacks: {
|
|
930
932
|
...t.callbacks,
|
|
931
933
|
onConnectionStateChange: (c) => {
|
|
932
934
|
var a, s;
|
|
933
|
-
(s = (a = t.callbacks).onConnectionStateChange) == null || s.call(a, c), c ===
|
|
935
|
+
(s = (a = t.callbacks).onConnectionStateChange) == null || s.call(a, c), c === R.Connected && r(o);
|
|
934
936
|
},
|
|
935
937
|
onVideoStateChange: (c, a) => {
|
|
936
938
|
var s, d;
|
|
937
|
-
(d = (s = t.callbacks).onVideoStateChange) == null || d.call(s, c),
|
|
939
|
+
(d = (s = t.callbacks).onVideoStateChange) == null || d.call(s, c), Rt(
|
|
938
940
|
c,
|
|
939
941
|
e,
|
|
940
942
|
a,
|
|
@@ -944,7 +946,7 @@ function Et(e, t, n) {
|
|
|
944
946
|
},
|
|
945
947
|
onAgentActivityStateChange: (c) => {
|
|
946
948
|
var a, s;
|
|
947
|
-
(s = (a = t.callbacks).onAgentActivityStateChange) == null || s.call(a, c), c === O.Talking ?
|
|
949
|
+
(s = (a = t.callbacks).onAgentActivityStateChange) == null || s.call(a, c), c === O.Talking ? ae.update() : ae.reset(), It(
|
|
948
950
|
c === O.Talking ? w.Start : w.Stop,
|
|
949
951
|
e,
|
|
950
952
|
n,
|
|
@@ -958,18 +960,18 @@ function Et(e, t, n) {
|
|
|
958
960
|
}
|
|
959
961
|
});
|
|
960
962
|
}
|
|
961
|
-
async function
|
|
962
|
-
var
|
|
963
|
-
const o =
|
|
964
|
-
return l && l !== t.mode && (t.mode = l, (M = (
|
|
963
|
+
async function _t(e, t, n, r, i) {
|
|
964
|
+
var y, M, j, b;
|
|
965
|
+
const o = ve(e, n, r, t.mode, t.persistentChat, i), c = Mt(e, t, r), [a, s] = await Promise.all([o, c]), { chat: d, chatMode: l } = a;
|
|
966
|
+
return l && l !== t.mode && (t.mode = l, (M = (y = t.callbacks).onModeChange) == null || M.call(y, l), l !== E.Functional) ? ((b = (j = t.callbacks).onError) == null || b.call(j, new Re(l)), s == null || s.disconnect(), { chat: d }) : { chat: d, streamingManager: s };
|
|
965
967
|
}
|
|
966
|
-
async function
|
|
967
|
-
var
|
|
968
|
+
async function At(e, t) {
|
|
969
|
+
var W, C, U;
|
|
968
970
|
let n = !0, r = null;
|
|
969
|
-
const i = t.mixpanelKey ||
|
|
971
|
+
const i = t.mixpanelKey || ze, o = t.wsURL || xe, c = t.baseURL || ee, a = {
|
|
970
972
|
messages: [],
|
|
971
973
|
chatMode: t.mode || E.Functional
|
|
972
|
-
}, s =
|
|
974
|
+
}, s = Oe({
|
|
973
975
|
token: i,
|
|
974
976
|
agentId: e,
|
|
975
977
|
isEnabled: t.enableAnalitics,
|
|
@@ -977,9 +979,9 @@ async function jt(e, t) {
|
|
|
977
979
|
mixpanelAdditionalProperties: t.mixpanelAdditionalProperties
|
|
978
980
|
});
|
|
979
981
|
s.track("agent-sdk", { event: "init" });
|
|
980
|
-
const d =
|
|
981
|
-
s.enrich(
|
|
982
|
-
const { onMessage:
|
|
982
|
+
const d = he(t.auth, c, t.callbacks.onError), l = await d.getById(e);
|
|
983
|
+
s.enrich(Ue(l));
|
|
984
|
+
const { onMessage: y, clearQueue: M } = nt(
|
|
983
985
|
s,
|
|
984
986
|
a,
|
|
985
987
|
t,
|
|
@@ -989,47 +991,47 @@ async function jt(e, t) {
|
|
|
989
991
|
return (u = a.socketManager) == null ? void 0 : u.disconnect();
|
|
990
992
|
}
|
|
991
993
|
);
|
|
992
|
-
a.messages =
|
|
993
|
-
const
|
|
994
|
+
a.messages = Xe(t.initialMessages), (C = (W = t.callbacks).onNewMessage) == null || C.call(W, [...a.messages], "answer");
|
|
995
|
+
const j = (u) => {
|
|
994
996
|
r = u;
|
|
995
997
|
};
|
|
996
|
-
s.track("agent-sdk", { event: "loaded", ...
|
|
997
|
-
async function
|
|
998
|
-
var
|
|
999
|
-
(
|
|
1000
|
-
const h = t.mode === E.DirectPlayback ? Promise.resolve(void 0) :
|
|
1001
|
-
() =>
|
|
998
|
+
s.track("agent-sdk", { event: "loaded", ...Ke(l) });
|
|
999
|
+
async function b(u) {
|
|
1000
|
+
var S, T, L, D, I, k, x;
|
|
1001
|
+
(T = (S = t.callbacks).onConnectionStateChange) == null || T.call(S, R.Connecting), $.reset(), u && !n && (delete a.chat, (D = (L = t.callbacks).onNewMessage) == null || D.call(L, [...a.messages], "answer"));
|
|
1002
|
+
const h = t.mode === E.DirectPlayback ? Promise.resolve(void 0) : et(t.auth, o, { onMessage: y, onError: t.callbacks.onError }), p = ne(
|
|
1003
|
+
() => _t(
|
|
1002
1004
|
l,
|
|
1003
|
-
{ ...t, callbacks: { ...t.callbacks, onVideoIdChange:
|
|
1005
|
+
{ ...t, callbacks: { ...t.callbacks, onVideoIdChange: j } },
|
|
1004
1006
|
d,
|
|
1005
1007
|
s,
|
|
1006
1008
|
a.chat
|
|
1007
1009
|
),
|
|
1008
1010
|
{
|
|
1009
1011
|
limit: 3,
|
|
1010
|
-
timeout:
|
|
1012
|
+
timeout: Be,
|
|
1011
1013
|
timeoutErrorMessage: "Timeout initializing the stream",
|
|
1012
1014
|
// Retry on all errors except for connection errors and rate limit errors, these are already handled in client level.
|
|
1013
|
-
shouldRetryFn: (
|
|
1015
|
+
shouldRetryFn: (B) => (B == null ? void 0 : B.message) !== "Could not connect" && B.status !== 429,
|
|
1014
1016
|
delayMs: 1e3
|
|
1015
1017
|
}
|
|
1016
|
-
).catch((
|
|
1017
|
-
var
|
|
1018
|
-
throw K(E.Maintenance), (
|
|
1019
|
-
}), [_, { streamingManager:
|
|
1020
|
-
|
|
1021
|
-
chatId:
|
|
1022
|
-
streamId:
|
|
1018
|
+
).catch((B) => {
|
|
1019
|
+
var F, N;
|
|
1020
|
+
throw K(E.Maintenance), (N = (F = t.callbacks).onConnectionStateChange) == null || N.call(F, R.Fail), B;
|
|
1021
|
+
}), [_, { streamingManager: v, chat: f }] = await Promise.all([h, p]);
|
|
1022
|
+
f && f.id !== ((I = a.chat) == null ? void 0 : I.id) && ((x = (k = t.callbacks).onNewChat) == null || x.call(k, f.id)), a.streamingManager = v, a.socketManager = _, a.chat = f, n = !1, s.enrich({
|
|
1023
|
+
chatId: f == null ? void 0 : f.id,
|
|
1024
|
+
streamId: v == null ? void 0 : v.streamId,
|
|
1023
1025
|
mode: a.chatMode
|
|
1024
|
-
}), K((
|
|
1026
|
+
}), K((f == null ? void 0 : f.chat_mode) ?? t.mode ?? E.Functional);
|
|
1025
1027
|
}
|
|
1026
|
-
async function
|
|
1028
|
+
async function z() {
|
|
1027
1029
|
var u, h, p, _;
|
|
1028
|
-
(u = a.socketManager) == null || u.disconnect(), await ((h = a.streamingManager) == null ? void 0 : h.disconnect()), delete a.streamingManager, delete a.socketManager, (_ = (p = t.callbacks).onConnectionStateChange) == null || _.call(p,
|
|
1030
|
+
(u = a.socketManager) == null || u.disconnect(), await ((h = a.streamingManager) == null ? void 0 : h.disconnect()), delete a.streamingManager, delete a.socketManager, (_ = (p = t.callbacks).onConnectionStateChange) == null || _.call(p, R.Disconnected);
|
|
1029
1031
|
}
|
|
1030
1032
|
async function K(u) {
|
|
1031
1033
|
var h, p;
|
|
1032
|
-
u !== a.chatMode && (s.track("agent-mode-change", { mode: u }), a.chatMode = u, a.chatMode !== E.Functional && await
|
|
1034
|
+
u !== a.chatMode && (s.track("agent-mode-change", { mode: u }), a.chatMode = u, a.chatMode !== E.Functional && await z(), (p = (h = t.callbacks).onModeChange) == null || p.call(h, u));
|
|
1033
1035
|
}
|
|
1034
1036
|
return {
|
|
1035
1037
|
agent: l,
|
|
@@ -1041,32 +1043,36 @@ async function jt(e, t) {
|
|
|
1041
1043
|
var u;
|
|
1042
1044
|
return ((u = a.streamingManager) == null ? void 0 : u.interruptAvailable) ?? !1;
|
|
1043
1045
|
},
|
|
1046
|
+
getIsTriggersAvailable: () => {
|
|
1047
|
+
var u;
|
|
1048
|
+
return ((u = a.streamingManager) == null ? void 0 : u.triggersAvailable) ?? !1;
|
|
1049
|
+
},
|
|
1044
1050
|
starterMessages: ((U = l.knowledge) == null ? void 0 : U.starter_message) || [],
|
|
1045
1051
|
getSTTToken: () => d.getSTTToken(l.id),
|
|
1046
1052
|
changeMode: K,
|
|
1047
1053
|
enrichAnalytics: s.enrich,
|
|
1048
1054
|
async connect() {
|
|
1049
|
-
await
|
|
1055
|
+
await b(!0), s.track("agent-chat", {
|
|
1050
1056
|
event: "connect",
|
|
1051
1057
|
mode: a.chatMode
|
|
1052
1058
|
});
|
|
1053
1059
|
},
|
|
1054
1060
|
async reconnect() {
|
|
1055
|
-
await
|
|
1061
|
+
await z(), await b(!1), s.track("agent-chat", {
|
|
1056
1062
|
event: "reconnect",
|
|
1057
1063
|
mode: a.chatMode
|
|
1058
1064
|
});
|
|
1059
1065
|
},
|
|
1060
1066
|
async disconnect() {
|
|
1061
|
-
await
|
|
1067
|
+
await z(), s.track("agent-chat", {
|
|
1062
1068
|
event: "disconnect",
|
|
1063
1069
|
mode: a.chatMode
|
|
1064
1070
|
});
|
|
1065
1071
|
},
|
|
1066
1072
|
async chat(u) {
|
|
1067
|
-
var
|
|
1073
|
+
var v, f, S, T, L;
|
|
1068
1074
|
const h = () => {
|
|
1069
|
-
if (
|
|
1075
|
+
if (ue(t.mode))
|
|
1070
1076
|
throw new H(`${t.mode} is enabled, chat is disabled`);
|
|
1071
1077
|
if (u.length >= 800)
|
|
1072
1078
|
throw new H("Message cannot be more than 800 characters");
|
|
@@ -1081,47 +1087,47 @@ async function jt(e, t) {
|
|
|
1081
1087
|
throw new H("Chat is not initialized");
|
|
1082
1088
|
}
|
|
1083
1089
|
}, p = async () => {
|
|
1084
|
-
var
|
|
1090
|
+
var D, I;
|
|
1085
1091
|
if (!a.chat) {
|
|
1086
|
-
const
|
|
1092
|
+
const k = await ve(
|
|
1087
1093
|
l,
|
|
1088
1094
|
d,
|
|
1089
1095
|
s,
|
|
1090
1096
|
a.chatMode,
|
|
1091
1097
|
t.persistentChat
|
|
1092
1098
|
);
|
|
1093
|
-
if (!
|
|
1094
|
-
throw new
|
|
1095
|
-
a.chat =
|
|
1099
|
+
if (!k.chat)
|
|
1100
|
+
throw new Ce(a.chatMode, !!t.persistentChat);
|
|
1101
|
+
a.chat = k.chat, (I = (D = t.callbacks).onNewChat) == null || I.call(D, a.chat.id);
|
|
1096
1102
|
}
|
|
1097
1103
|
return a.chat.id;
|
|
1098
|
-
}, _ = async (
|
|
1104
|
+
}, _ = async (D, I) => ne(
|
|
1099
1105
|
() => {
|
|
1100
|
-
var
|
|
1106
|
+
var k, x;
|
|
1101
1107
|
return d.chat(
|
|
1102
1108
|
l.id,
|
|
1103
1109
|
I,
|
|
1104
1110
|
{
|
|
1105
1111
|
chatMode: a.chatMode,
|
|
1106
|
-
streamId: (
|
|
1112
|
+
streamId: (k = a.streamingManager) == null ? void 0 : k.streamId,
|
|
1107
1113
|
sessionId: (x = a.streamingManager) == null ? void 0 : x.sessionId,
|
|
1108
|
-
messages:
|
|
1114
|
+
messages: D.map(({ matches: B, ...F }) => F)
|
|
1109
1115
|
},
|
|
1110
1116
|
{
|
|
1111
|
-
...
|
|
1117
|
+
...ye(a.chatMode),
|
|
1112
1118
|
skipErrorHandler: !0
|
|
1113
1119
|
}
|
|
1114
1120
|
);
|
|
1115
1121
|
},
|
|
1116
1122
|
{
|
|
1117
1123
|
limit: 2,
|
|
1118
|
-
shouldRetryFn: (
|
|
1119
|
-
var
|
|
1120
|
-
const x = (
|
|
1121
|
-
return !((
|
|
1124
|
+
shouldRetryFn: (k) => {
|
|
1125
|
+
var F, N, X, Y;
|
|
1126
|
+
const x = (F = k == null ? void 0 : k.message) == null ? void 0 : F.includes("missing or invalid session_id");
|
|
1127
|
+
return !((N = k == null ? void 0 : k.message) == null ? void 0 : N.includes("Stream Error")) && !x ? ((Y = (X = t.callbacks).onError) == null || Y.call(X, k), !1) : !0;
|
|
1122
1128
|
},
|
|
1123
1129
|
onRetry: async () => {
|
|
1124
|
-
await
|
|
1130
|
+
await z(), await b(!1);
|
|
1125
1131
|
}
|
|
1126
1132
|
}
|
|
1127
1133
|
);
|
|
@@ -1130,9 +1136,9 @@ async function jt(e, t) {
|
|
|
1130
1136
|
id: V(),
|
|
1131
1137
|
role: "user",
|
|
1132
1138
|
content: u,
|
|
1133
|
-
created_at: new Date(
|
|
1134
|
-
}), (
|
|
1135
|
-
const
|
|
1139
|
+
created_at: new Date($.update()).toISOString()
|
|
1140
|
+
}), (f = (v = t.callbacks).onNewMessage) == null || f.call(v, [...a.messages], "user");
|
|
1141
|
+
const D = await p(), I = await _([...a.messages], D);
|
|
1136
1142
|
return a.messages.push({
|
|
1137
1143
|
id: V(),
|
|
1138
1144
|
role: "assistant",
|
|
@@ -1143,40 +1149,40 @@ async function jt(e, t) {
|
|
|
1143
1149
|
}), s.track("agent-message-send", {
|
|
1144
1150
|
event: "success",
|
|
1145
1151
|
messages: a.messages.length + 1
|
|
1146
|
-
}), I.result && ((
|
|
1147
|
-
latency:
|
|
1152
|
+
}), I.result && ((T = (S = t.callbacks).onNewMessage) == null || T.call(S, [...a.messages], "answer"), s.track("agent-message-received", {
|
|
1153
|
+
latency: $.get(!0),
|
|
1148
1154
|
messages: a.messages.length
|
|
1149
1155
|
})), I;
|
|
1150
|
-
} catch (
|
|
1151
|
-
throw ((
|
|
1156
|
+
} catch (D) {
|
|
1157
|
+
throw ((L = a.messages[a.messages.length - 1]) == null ? void 0 : L.role) === "assistant" && a.messages.pop(), s.track("agent-message-send", {
|
|
1152
1158
|
event: "error",
|
|
1153
1159
|
messages: a.messages.length
|
|
1154
|
-
}),
|
|
1160
|
+
}), D;
|
|
1155
1161
|
}
|
|
1156
1162
|
},
|
|
1157
1163
|
rate(u, h, p) {
|
|
1158
|
-
var
|
|
1159
|
-
const _ = a.messages.find((
|
|
1164
|
+
var f, S, T, L;
|
|
1165
|
+
const _ = a.messages.find((D) => D.id === u);
|
|
1160
1166
|
if (a.chat) {
|
|
1161
1167
|
if (!_)
|
|
1162
1168
|
throw new Error("Message not found");
|
|
1163
1169
|
} else throw new Error("Chat is not initialized");
|
|
1164
|
-
const
|
|
1170
|
+
const v = ((f = _.matches) == null ? void 0 : f.map((D) => [D.document_id, D.id])) ?? [];
|
|
1165
1171
|
return s.track("agent-rate", {
|
|
1166
1172
|
event: p ? "update" : "create",
|
|
1167
1173
|
thumb: h === 1 ? "up" : "down",
|
|
1168
|
-
knowledge_id: ((
|
|
1169
|
-
matches:
|
|
1174
|
+
knowledge_id: ((S = l.knowledge) == null ? void 0 : S.id) ?? "",
|
|
1175
|
+
matches: v,
|
|
1170
1176
|
score: h
|
|
1171
1177
|
}), p ? d.updateRating(l.id, a.chat.id, p, {
|
|
1172
|
-
knowledge_id: ((
|
|
1178
|
+
knowledge_id: ((T = l.knowledge) == null ? void 0 : T.id) ?? "",
|
|
1173
1179
|
message_id: u,
|
|
1174
|
-
matches:
|
|
1180
|
+
matches: v,
|
|
1175
1181
|
score: h
|
|
1176
1182
|
}) : d.createRating(l.id, a.chat.id, {
|
|
1177
|
-
knowledge_id: ((
|
|
1183
|
+
knowledge_id: ((L = l.knowledge) == null ? void 0 : L.id) ?? "",
|
|
1178
1184
|
message_id: u,
|
|
1179
|
-
matches:
|
|
1185
|
+
matches: v,
|
|
1180
1186
|
score: h
|
|
1181
1187
|
});
|
|
1182
1188
|
},
|
|
@@ -1186,7 +1192,7 @@ async function jt(e, t) {
|
|
|
1186
1192
|
return s.track("agent-rate-delete", { type: "text" }), d.deleteRating(l.id, a.chat.id, u);
|
|
1187
1193
|
},
|
|
1188
1194
|
async speak(u) {
|
|
1189
|
-
var
|
|
1195
|
+
var v, f, S;
|
|
1190
1196
|
function h() {
|
|
1191
1197
|
if (typeof u == "string") {
|
|
1192
1198
|
if (!l.presenter.voice)
|
|
@@ -1211,12 +1217,12 @@ async function jt(e, t) {
|
|
|
1211
1217
|
return u;
|
|
1212
1218
|
}
|
|
1213
1219
|
const p = h();
|
|
1214
|
-
if (s.track("agent-speak", p),
|
|
1220
|
+
if (s.track("agent-speak", p), $.update(), a.messages && p.type === "text" && (a.messages.push({
|
|
1215
1221
|
id: V(),
|
|
1216
1222
|
role: "assistant",
|
|
1217
1223
|
content: p.input,
|
|
1218
|
-
created_at: new Date(
|
|
1219
|
-
}), (
|
|
1224
|
+
created_at: new Date($.get(!0)).toISOString()
|
|
1225
|
+
}), (f = (v = t.callbacks).onNewMessage) == null || f.call(v, [...a.messages], "answer")), Fe(a.chatMode))
|
|
1220
1226
|
return {
|
|
1221
1227
|
duration: 0,
|
|
1222
1228
|
video_id: "",
|
|
@@ -1226,53 +1232,53 @@ async function jt(e, t) {
|
|
|
1226
1232
|
throw new Error("Please connect to the agent first");
|
|
1227
1233
|
return a.streamingManager.speak({
|
|
1228
1234
|
script: p,
|
|
1229
|
-
metadata: { chat_id: (
|
|
1235
|
+
metadata: { chat_id: (S = a.chat) == null ? void 0 : S.id, agent_id: l.id }
|
|
1230
1236
|
});
|
|
1231
1237
|
},
|
|
1232
1238
|
async interrupt({ type: u }) {
|
|
1233
|
-
var p, _,
|
|
1234
|
-
|
|
1239
|
+
var p, _, v;
|
|
1240
|
+
Ye(a.streamingManager, (p = a.streamingManager) == null ? void 0 : p.streamType, r);
|
|
1235
1241
|
const h = a.messages[a.messages.length - 1];
|
|
1236
1242
|
s.track("agent-video-interrupt", {
|
|
1237
1243
|
type: u || "click",
|
|
1238
|
-
video_duration_to_interrupt:
|
|
1239
|
-
message_duration_to_interrupt:
|
|
1240
|
-
}), h.interrupted = !0, (
|
|
1244
|
+
video_duration_to_interrupt: ae.get(!0),
|
|
1245
|
+
message_duration_to_interrupt: $.get(!0)
|
|
1246
|
+
}), h.interrupted = !0, (v = (_ = t.callbacks).onNewMessage) == null || v.call(_, [...a.messages], "answer"), Qe(a.streamingManager, r);
|
|
1241
1247
|
}
|
|
1242
1248
|
};
|
|
1243
1249
|
}
|
|
1244
|
-
function
|
|
1245
|
-
const { getById: r } =
|
|
1250
|
+
function bt(e, t, n) {
|
|
1251
|
+
const { getById: r } = he(t, n || ee);
|
|
1246
1252
|
return r(e);
|
|
1247
1253
|
}
|
|
1248
1254
|
export {
|
|
1249
1255
|
O as A,
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1256
|
+
R as C,
|
|
1257
|
+
Ae as D,
|
|
1258
|
+
je as K,
|
|
1259
|
+
Ee as P,
|
|
1260
|
+
_e as R,
|
|
1261
|
+
J as S,
|
|
1262
|
+
be as T,
|
|
1263
|
+
Ie as U,
|
|
1258
1264
|
H as V,
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1265
|
+
Se as W,
|
|
1266
|
+
it as a,
|
|
1267
|
+
G as b,
|
|
1268
|
+
ge as c,
|
|
1263
1269
|
w as d,
|
|
1264
1270
|
P as e,
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
+
ee as f,
|
|
1272
|
+
Ce as g,
|
|
1273
|
+
Re as h,
|
|
1274
|
+
At as i,
|
|
1275
|
+
bt as j,
|
|
1276
|
+
Me as k,
|
|
1271
1277
|
E as l,
|
|
1272
1278
|
q as m,
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1279
|
+
Te as n,
|
|
1280
|
+
de as o,
|
|
1281
|
+
jt as p,
|
|
1276
1282
|
Pe as q,
|
|
1277
|
-
|
|
1283
|
+
Le as r
|
|
1278
1284
|
};
|