@d-id/client-sdk 1.1.11-staging.41 → 1.1.11-staging.43
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-UeXWrNlF.js → index-BHt2AhLb.js} +345 -335
- package/dist/index.js +1 -1
- package/dist/index.umd.cjs +5 -5
- package/dist/{livekit-manager-6i5Rpchn.js → livekit-manager-DZ_BAT5P.js} +3 -2
- package/dist/src/services/analytics/mixpanel.d.ts +1 -0
- package/dist/src/services/streaming-manager/common.d.ts +4 -0
- package/dist/src/types/entities/agents/manager.d.ts +5 -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,15 +234,18 @@ 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
|
-
additionalProperties: {
|
|
245
|
+
additionalProperties: {
|
|
246
|
+
id: e.distinctId,
|
|
247
|
+
...e.mixpanelAdditionalProperties || {}
|
|
248
|
+
},
|
|
246
249
|
isEnabled: e.isEnabled ?? !0,
|
|
247
250
|
getRandom: V,
|
|
248
251
|
enrich(n) {
|
|
@@ -278,14 +281,14 @@ function Ve(e) {
|
|
|
278
281
|
})
|
|
279
282
|
};
|
|
280
283
|
try {
|
|
281
|
-
return await fetch(
|
|
284
|
+
return await fetch(Ve, c).then((a) => a.json());
|
|
282
285
|
} catch (a) {
|
|
283
286
|
return console.error(a);
|
|
284
287
|
}
|
|
285
288
|
},
|
|
286
289
|
linkTrack(n, r, i, o) {
|
|
287
|
-
|
|
288
|
-
const c =
|
|
290
|
+
re[n] || (re[n] = { events: {}, resolvedDependencies: [] }), o.includes(i) || o.push(i);
|
|
291
|
+
const c = re[n];
|
|
289
292
|
if (c.events[i] = { props: r }, c.resolvedDependencies.push(i), o.every(
|
|
290
293
|
(s) => c.resolvedDependencies.includes(s)
|
|
291
294
|
)) {
|
|
@@ -299,7 +302,7 @@ function Ve(e) {
|
|
|
299
302
|
}
|
|
300
303
|
};
|
|
301
304
|
}
|
|
302
|
-
function
|
|
305
|
+
function pe() {
|
|
303
306
|
let e = 0;
|
|
304
307
|
return {
|
|
305
308
|
reset: () => e = 0,
|
|
@@ -307,13 +310,13 @@ function we() {
|
|
|
307
310
|
get: (t = !1) => t ? Date.now() - e : e
|
|
308
311
|
};
|
|
309
312
|
}
|
|
310
|
-
const
|
|
311
|
-
function
|
|
312
|
-
return e === E.Playground ? { headers: { [
|
|
313
|
+
const $ = pe(), ae = pe();
|
|
314
|
+
function ye(e) {
|
|
315
|
+
return e === E.Playground ? { headers: { [$e]: "true" } } : {};
|
|
313
316
|
}
|
|
314
|
-
async function
|
|
317
|
+
async function ve(e, t, n, r, i = !1, o) {
|
|
315
318
|
try {
|
|
316
|
-
return !o && !
|
|
319
|
+
return !o && !ue(r) && (o = await t.newChat(e.id, { persist: i }, ye(r)), n.track("agent-chat", {
|
|
317
320
|
event: "created",
|
|
318
321
|
chatId: o.id,
|
|
319
322
|
mode: r
|
|
@@ -329,58 +332,58 @@ async function ye(e, t, n, r, i = !1, o) {
|
|
|
329
332
|
throw new Error("Cannot create new chat");
|
|
330
333
|
}
|
|
331
334
|
}
|
|
332
|
-
function
|
|
335
|
+
function Xe(e) {
|
|
333
336
|
return e && e.length > 0 ? e : [];
|
|
334
337
|
}
|
|
335
|
-
function
|
|
338
|
+
function Ye(e, t, n) {
|
|
336
339
|
if (!e)
|
|
337
340
|
throw new Error("Please connect to the agent first");
|
|
338
341
|
if (!e.interruptAvailable)
|
|
339
342
|
throw new Error("Interrupt is not enabled for this stream");
|
|
340
|
-
if (t !==
|
|
343
|
+
if (t !== J.Fluent)
|
|
341
344
|
throw new Error("Interrupt only available for Fluent streams");
|
|
342
345
|
if (!n)
|
|
343
346
|
throw new Error("No active video to interrupt");
|
|
344
347
|
}
|
|
345
|
-
async function
|
|
348
|
+
async function Qe(e, t) {
|
|
346
349
|
const n = {
|
|
347
|
-
type:
|
|
350
|
+
type: P.StreamInterrupt,
|
|
348
351
|
videoId: t,
|
|
349
352
|
timestamp: Date.now()
|
|
350
353
|
};
|
|
351
354
|
e.sendDataChannelMessage(JSON.stringify(n));
|
|
352
355
|
}
|
|
353
|
-
function
|
|
356
|
+
function Ze(e) {
|
|
354
357
|
return new Promise((t, n) => {
|
|
355
|
-
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=${
|
|
356
|
-
l.onmessage = c, l.onclose = s, l.onerror = (
|
|
357
|
-
console.error(
|
|
358
|
-
}, l.onopen = (
|
|
359
|
-
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);
|
|
360
363
|
};
|
|
361
364
|
});
|
|
362
365
|
}
|
|
363
|
-
async function
|
|
366
|
+
async function Ge(e) {
|
|
364
367
|
const { retries: t = 1 } = e;
|
|
365
368
|
let n = null;
|
|
366
369
|
for (let r = 0; (n == null ? void 0 : n.readyState) !== WebSocket.OPEN; r++)
|
|
367
370
|
try {
|
|
368
|
-
n = await
|
|
371
|
+
n = await Ze(e);
|
|
369
372
|
} catch (i) {
|
|
370
373
|
if (r === t)
|
|
371
374
|
throw i;
|
|
372
|
-
await
|
|
375
|
+
await le(r * 500);
|
|
373
376
|
}
|
|
374
377
|
return n;
|
|
375
378
|
}
|
|
376
|
-
async function
|
|
377
|
-
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({
|
|
378
381
|
auth: e,
|
|
379
382
|
host: t,
|
|
380
383
|
callbacks: {
|
|
381
384
|
onError: (o) => {
|
|
382
385
|
var c;
|
|
383
|
-
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));
|
|
384
387
|
},
|
|
385
388
|
onMessage(o) {
|
|
386
389
|
const c = JSON.parse(o.data);
|
|
@@ -394,7 +397,7 @@ async function Ge(e, t, n) {
|
|
|
394
397
|
subscribeToEvents: (o) => r.push(o)
|
|
395
398
|
};
|
|
396
399
|
}
|
|
397
|
-
function
|
|
400
|
+
function tt(e) {
|
|
398
401
|
if (e.answer !== void 0)
|
|
399
402
|
return e.answer;
|
|
400
403
|
let t = 0, n = "";
|
|
@@ -402,41 +405,41 @@ function et(e) {
|
|
|
402
405
|
n += e[t++];
|
|
403
406
|
return n;
|
|
404
407
|
}
|
|
405
|
-
function
|
|
408
|
+
function rt(e, t, n, r, i) {
|
|
406
409
|
const o = r.messages[r.messages.length - 1];
|
|
407
410
|
if (!(e === q.Partial || e === q.Answer) || (o == null ? void 0 : o.role) !== "assistant")
|
|
408
411
|
return;
|
|
409
412
|
const { content: c, sequence: a } = t;
|
|
410
413
|
e === q.Partial ? n[a] = c : n.answer = c;
|
|
411
|
-
const s =
|
|
414
|
+
const s = tt(n);
|
|
412
415
|
(o.content !== s || e === q.Answer) && (o.content = s, i == null || i([...r.messages], e));
|
|
413
416
|
}
|
|
414
|
-
function
|
|
417
|
+
function nt(e, t, n, r, i) {
|
|
415
418
|
let o = {};
|
|
416
419
|
return {
|
|
417
420
|
clearQueue: () => o = {},
|
|
418
421
|
onMessage: (c, a) => {
|
|
419
422
|
var s, d;
|
|
420
423
|
if ("content" in a)
|
|
421
|
-
|
|
424
|
+
rt(c, a, o, t, n.callbacks.onNewMessage), c === q.Answer && e.track("agent-message-received", {
|
|
422
425
|
messages: t.messages.length,
|
|
423
426
|
mode: t.chatMode
|
|
424
427
|
});
|
|
425
428
|
else {
|
|
426
|
-
const l =
|
|
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 });
|
|
427
430
|
if (c = c, c === l.StreamVideoCreated)
|
|
428
|
-
e.linkTrack("agent-video",
|
|
429
|
-
else if (
|
|
431
|
+
e.linkTrack("agent-video", j, l.StreamVideoCreated, ["start"]);
|
|
432
|
+
else if (y.includes(c)) {
|
|
430
433
|
const b = c.split("/")[1];
|
|
431
|
-
M.includes(c) ? e.track("agent-video", { ...
|
|
434
|
+
M.includes(c) ? e.track("agent-video", { ...j, event: b }) : e.linkTrack("agent-video", { ...j, event: b }, c, ["done"]);
|
|
432
435
|
}
|
|
433
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();
|
|
434
437
|
}
|
|
435
438
|
}
|
|
436
439
|
};
|
|
437
440
|
}
|
|
438
|
-
function
|
|
439
|
-
const i =
|
|
441
|
+
function at(e, t, n, r) {
|
|
442
|
+
const i = ge(e, `${t}/agents/${n}`, r);
|
|
440
443
|
return {
|
|
441
444
|
createStream(o) {
|
|
442
445
|
return i.post("/streams", o);
|
|
@@ -464,8 +467,8 @@ function nt(e, t, n, r) {
|
|
|
464
467
|
}
|
|
465
468
|
};
|
|
466
469
|
}
|
|
467
|
-
const
|
|
468
|
-
function
|
|
470
|
+
const it = (e, t) => (n, r) => e && console.log(`[${t}] ${n}`, r ?? "");
|
|
471
|
+
function st(e, t, n) {
|
|
469
472
|
const r = (t.timestamp - e.timestamp) / 1e3;
|
|
470
473
|
return {
|
|
471
474
|
duration: r,
|
|
@@ -485,7 +488,7 @@ function it(e, t, n) {
|
|
|
485
488
|
lowFpsCount: n
|
|
486
489
|
};
|
|
487
490
|
}
|
|
488
|
-
function
|
|
491
|
+
function ot(e) {
|
|
489
492
|
return e.filter(
|
|
490
493
|
(t) => t.freezeCount > 0 || t.framesPerSecond < 21 || t.framesDropped > 0 || t.packetsLost > 0
|
|
491
494
|
).map((t) => {
|
|
@@ -496,7 +499,7 @@ function st(e) {
|
|
|
496
499
|
};
|
|
497
500
|
});
|
|
498
501
|
}
|
|
499
|
-
function
|
|
502
|
+
function ct(e) {
|
|
500
503
|
let t = "", n = 0;
|
|
501
504
|
for (const r of e.values())
|
|
502
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")
|
|
@@ -521,7 +524,7 @@ function ot(e) {
|
|
|
521
524
|
};
|
|
522
525
|
return {};
|
|
523
526
|
}
|
|
524
|
-
function
|
|
527
|
+
function dt(e, t, n) {
|
|
525
528
|
const r = e.map((s, d) => d === 0 ? n ? {
|
|
526
529
|
timestamp: s.timestamp,
|
|
527
530
|
duration: 0,
|
|
@@ -573,32 +576,32 @@ function ct(e, t, n) {
|
|
|
573
576
|
framesPerSecond: s.framesPerSecond,
|
|
574
577
|
freezeCount: s.freezeCount - e[d - 1].freezeCount,
|
|
575
578
|
freezeDuration: s.freezeDuration - e[d - 1].freezeDuration
|
|
576
|
-
}), 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);
|
|
577
580
|
return {
|
|
578
581
|
webRTCStats: {
|
|
579
582
|
anomalies: i,
|
|
580
583
|
minRtt: Math.min(...a),
|
|
581
|
-
avgRtt:
|
|
584
|
+
avgRtt: se(a),
|
|
582
585
|
maxRtt: Math.max(...a),
|
|
583
|
-
aggregateReport:
|
|
586
|
+
aggregateReport: st(e[0], e[e.length - 1], o),
|
|
584
587
|
minJitterDelayInInterval: Math.min(...c),
|
|
585
588
|
maxJitterDelayInInterval: Math.max(...c),
|
|
586
|
-
avgJitterDelayInInterval:
|
|
589
|
+
avgJitterDelayInInterval: se(c)
|
|
587
590
|
},
|
|
588
591
|
codec: e[0].codec,
|
|
589
592
|
resolution: `${e[0].frameWidth}x${e[0].frameHeight}`
|
|
590
593
|
};
|
|
591
594
|
}
|
|
592
|
-
const
|
|
593
|
-
function
|
|
595
|
+
const ie = 100, lt = Math.max(Math.ceil(400 / ie), 1), ut = 0.25, ft = 0.28;
|
|
596
|
+
function mt() {
|
|
594
597
|
let e = 0, t, n, r = 0;
|
|
595
598
|
return (i) => {
|
|
596
599
|
for (const o of i.values())
|
|
597
600
|
if (o && o.type === "inbound-rtp" && o.kind === "video") {
|
|
598
601
|
const c = o.jitterBufferDelay, a = o.jitterBufferEmittedCount;
|
|
599
602
|
if (n && a > n) {
|
|
600
|
-
const l = c - t,
|
|
601
|
-
r = l /
|
|
603
|
+
const l = c - t, y = a - n;
|
|
604
|
+
r = l / y;
|
|
602
605
|
}
|
|
603
606
|
t = c, n = a;
|
|
604
607
|
const s = o.framesDecoded, d = s - e > 0;
|
|
@@ -607,41 +610,41 @@ function ft() {
|
|
|
607
610
|
return { isReceiving: !1, avgJitterDelayInInterval: r };
|
|
608
611
|
};
|
|
609
612
|
}
|
|
610
|
-
function
|
|
611
|
-
let c = [], a, s = 0, d = !1, l =
|
|
612
|
-
const b =
|
|
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();
|
|
613
616
|
return setInterval(async () => {
|
|
614
|
-
const
|
|
617
|
+
const z = await e.getStats(), { isReceiving: K, avgJitterDelayInInterval: W, freezeCount: C } = b(z), U = ct(z);
|
|
615
618
|
if (K)
|
|
616
|
-
s = 0, M =
|
|
617
|
-
else if (d && (s++, s >=
|
|
618
|
-
const u =
|
|
619
|
-
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;
|
|
620
623
|
}
|
|
621
|
-
},
|
|
624
|
+
}, ie);
|
|
622
625
|
}
|
|
623
|
-
const
|
|
624
|
-
function
|
|
626
|
+
const ht = (window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection).bind(window);
|
|
627
|
+
function oe(e) {
|
|
625
628
|
switch (e) {
|
|
626
629
|
case "connected":
|
|
627
|
-
return
|
|
630
|
+
return R.Connected;
|
|
628
631
|
case "checking":
|
|
629
|
-
return
|
|
632
|
+
return R.Connecting;
|
|
630
633
|
case "failed":
|
|
631
|
-
return
|
|
634
|
+
return R.Fail;
|
|
632
635
|
case "new":
|
|
633
|
-
return
|
|
636
|
+
return R.New;
|
|
634
637
|
case "closed":
|
|
635
|
-
return
|
|
638
|
+
return R.Closed;
|
|
636
639
|
case "disconnected":
|
|
637
|
-
return
|
|
640
|
+
return R.Disconnected;
|
|
638
641
|
case "completed":
|
|
639
|
-
return
|
|
642
|
+
return R.Completed;
|
|
640
643
|
default:
|
|
641
|
-
return
|
|
644
|
+
return R.New;
|
|
642
645
|
}
|
|
643
646
|
}
|
|
644
|
-
const
|
|
647
|
+
const wt = (e) => (t) => {
|
|
645
648
|
const [n, r = ""] = t.split(/:(.+)/);
|
|
646
649
|
try {
|
|
647
650
|
const i = JSON.parse(r);
|
|
@@ -650,7 +653,7 @@ const ht = (e) => (t) => {
|
|
|
650
653
|
return e("Failed to parse data channel message, returning data as string", { subject: n, rawData: r, error: i }), { subject: n, data: r };
|
|
651
654
|
}
|
|
652
655
|
};
|
|
653
|
-
function
|
|
656
|
+
function pt({
|
|
654
657
|
statsSignal: e,
|
|
655
658
|
dataChannelSignal: t,
|
|
656
659
|
onVideoStateChange: n,
|
|
@@ -658,7 +661,7 @@ function wt({
|
|
|
658
661
|
}) {
|
|
659
662
|
e === w.Start && t === w.Start ? n == null || n(w.Start) : e === w.Stop && t === w.Stop && (n == null || n(w.Stop, r));
|
|
660
663
|
}
|
|
661
|
-
function
|
|
664
|
+
function yt({
|
|
662
665
|
statsSignal: e,
|
|
663
666
|
dataChannelSignal: t,
|
|
664
667
|
onVideoStateChange: n,
|
|
@@ -667,7 +670,7 @@ function pt({
|
|
|
667
670
|
}) {
|
|
668
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));
|
|
669
672
|
}
|
|
670
|
-
function
|
|
673
|
+
function ce({
|
|
671
674
|
statsSignal: e,
|
|
672
675
|
dataChannelSignal: t,
|
|
673
676
|
onVideoStateChange: n,
|
|
@@ -675,7 +678,7 @@ function oe({
|
|
|
675
678
|
streamType: i,
|
|
676
679
|
report: o
|
|
677
680
|
}) {
|
|
678
|
-
i ===
|
|
681
|
+
i === J.Legacy ? pt({ statsSignal: e, dataChannelSignal: t, onVideoStateChange: n, report: o }) : i === J.Fluent && yt({
|
|
679
682
|
statsSignal: e,
|
|
680
683
|
dataChannelSignal: t,
|
|
681
684
|
onVideoStateChange: n,
|
|
@@ -683,157 +686,158 @@ function oe({
|
|
|
683
686
|
report: o
|
|
684
687
|
});
|
|
685
688
|
}
|
|
686
|
-
async function
|
|
687
|
-
var
|
|
688
|
-
const a =
|
|
689
|
-
let d = !1, l = !1,
|
|
690
|
-
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(
|
|
691
694
|
i,
|
|
692
695
|
o,
|
|
693
696
|
e,
|
|
694
697
|
r.onError
|
|
695
698
|
), {
|
|
696
|
-
id:
|
|
699
|
+
id: C,
|
|
697
700
|
offer: U,
|
|
698
701
|
ice_servers: u,
|
|
699
702
|
session_id: h,
|
|
700
703
|
fluent: p,
|
|
701
|
-
interrupt_enabled: _
|
|
704
|
+
interrupt_enabled: _,
|
|
705
|
+
triggers_enabled: v
|
|
702
706
|
} = await K(t);
|
|
703
|
-
(
|
|
704
|
-
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");
|
|
705
709
|
if (!h)
|
|
706
710
|
throw new Error("Could not create session_id");
|
|
707
|
-
const
|
|
711
|
+
const T = p ? J.Fluent : J.Legacy;
|
|
708
712
|
c.enrich({
|
|
709
|
-
"stream-type":
|
|
713
|
+
"stream-type": T
|
|
710
714
|
});
|
|
711
|
-
const
|
|
712
|
-
var
|
|
713
|
-
d = !0, l && ((
|
|
714
|
-
},
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
(
|
|
719
|
-
statsSignal: M =
|
|
720
|
-
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,
|
|
721
725
|
onVideoStateChange: r.onVideoStateChange,
|
|
722
726
|
onAgentActivityStateChange: r.onAgentActivityStateChange,
|
|
723
727
|
report: g,
|
|
724
|
-
streamType:
|
|
728
|
+
streamType: T
|
|
725
729
|
}),
|
|
726
|
-
(
|
|
730
|
+
(m) => {
|
|
727
731
|
var g;
|
|
728
|
-
return (g = r.onConnectivityStateChange) == null ? void 0 : g.call(r,
|
|
732
|
+
return (g = r.onConnectivityStateChange) == null ? void 0 : g.call(r, m);
|
|
729
733
|
},
|
|
730
|
-
|
|
734
|
+
L
|
|
731
735
|
);
|
|
732
|
-
|
|
736
|
+
f.onicecandidate = (m) => {
|
|
733
737
|
var g;
|
|
734
|
-
a("peerConnection.onicecandidate",
|
|
738
|
+
a("peerConnection.onicecandidate", m);
|
|
735
739
|
try {
|
|
736
|
-
|
|
737
|
-
|
|
740
|
+
m.candidate && m.candidate.sdpMid && m.candidate.sdpMLineIndex !== null ? W(
|
|
741
|
+
C,
|
|
738
742
|
{
|
|
739
|
-
candidate:
|
|
740
|
-
sdpMid:
|
|
741
|
-
sdpMLineIndex:
|
|
743
|
+
candidate: m.candidate.candidate,
|
|
744
|
+
sdpMid: m.candidate.sdpMid,
|
|
745
|
+
sdpMLineIndex: m.candidate.sdpMLineIndex
|
|
742
746
|
},
|
|
743
747
|
h
|
|
744
|
-
) :
|
|
745
|
-
} catch (
|
|
746
|
-
(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 });
|
|
747
751
|
}
|
|
748
|
-
},
|
|
749
|
-
l = !0, (!
|
|
752
|
+
}, S.onopen = () => {
|
|
753
|
+
l = !0, (!L || d) && I();
|
|
750
754
|
};
|
|
751
|
-
const
|
|
755
|
+
const x = (m) => {
|
|
752
756
|
var g;
|
|
753
|
-
(g = r.onVideoIdChange) == null || g.call(r,
|
|
757
|
+
(g = r.onVideoIdChange) == null || g.call(r, m);
|
|
754
758
|
};
|
|
755
|
-
function
|
|
756
|
-
if (
|
|
757
|
-
const
|
|
758
|
-
|
|
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);
|
|
759
763
|
}
|
|
760
|
-
|
|
761
|
-
statsSignal:
|
|
762
|
-
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,
|
|
763
767
|
onVideoStateChange: r.onVideoStateChange,
|
|
764
768
|
onAgentActivityStateChange: r.onAgentActivityStateChange,
|
|
765
|
-
streamType:
|
|
769
|
+
streamType: T
|
|
766
770
|
});
|
|
767
771
|
}
|
|
768
|
-
function
|
|
769
|
-
const
|
|
770
|
-
|
|
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" });
|
|
771
775
|
}
|
|
772
|
-
const
|
|
773
|
-
[
|
|
774
|
-
[
|
|
775
|
-
[
|
|
776
|
+
const N = {
|
|
777
|
+
[P.StreamStarted]: B,
|
|
778
|
+
[P.StreamDone]: B,
|
|
779
|
+
[P.StreamReady]: F
|
|
776
780
|
};
|
|
777
|
-
|
|
778
|
-
var
|
|
779
|
-
const { subject: g, data:
|
|
780
|
-
(
|
|
781
|
-
},
|
|
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 = () => {
|
|
782
786
|
var g;
|
|
783
|
-
a("peerConnection.oniceconnectionstatechange => " +
|
|
784
|
-
const
|
|
785
|
-
|
|
786
|
-
},
|
|
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) => {
|
|
787
791
|
var g;
|
|
788
|
-
a("peerConnection.ontrack",
|
|
789
|
-
}, await
|
|
790
|
-
const
|
|
791
|
-
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"), {
|
|
792
796
|
/**
|
|
793
797
|
* Method to send request to server to get clip or talk depend on you payload
|
|
794
798
|
* @param payload
|
|
795
799
|
*/
|
|
796
|
-
speak(
|
|
797
|
-
return b(
|
|
800
|
+
speak(m) {
|
|
801
|
+
return b(C, h, m);
|
|
798
802
|
},
|
|
799
803
|
/**
|
|
800
804
|
* Method to close RTC connection
|
|
801
805
|
*/
|
|
802
806
|
async disconnect() {
|
|
803
|
-
var
|
|
804
|
-
if (
|
|
805
|
-
const g =
|
|
806
|
-
if (
|
|
807
|
-
if (g ===
|
|
808
|
-
clearInterval(
|
|
807
|
+
var m;
|
|
808
|
+
if (C) {
|
|
809
|
+
const g = oe(f.iceConnectionState);
|
|
810
|
+
if (f) {
|
|
811
|
+
if (g === R.New) {
|
|
812
|
+
clearInterval(k);
|
|
809
813
|
return;
|
|
810
814
|
}
|
|
811
|
-
|
|
815
|
+
f.close(), f.oniceconnectionstatechange = null, f.onnegotiationneeded = null, f.onicecandidate = null, f.ontrack = null;
|
|
812
816
|
}
|
|
813
817
|
try {
|
|
814
|
-
g ===
|
|
818
|
+
g === R.Connected && await z(C, h).catch((A) => {
|
|
815
819
|
});
|
|
816
|
-
} catch (
|
|
817
|
-
a("Error on close stream connection",
|
|
820
|
+
} catch (A) {
|
|
821
|
+
a("Error on close stream connection", A);
|
|
818
822
|
}
|
|
819
|
-
(
|
|
823
|
+
(m = r.onAgentActivityStateChange) == null || m.call(r, O.Idle), clearInterval(k);
|
|
820
824
|
}
|
|
821
825
|
},
|
|
822
826
|
/**
|
|
823
827
|
* Method to send data channel messages to the server
|
|
824
828
|
*/
|
|
825
|
-
sendDataChannelMessage(
|
|
826
|
-
var g,
|
|
827
|
-
if (!d ||
|
|
829
|
+
sendDataChannelMessage(m) {
|
|
830
|
+
var g, A;
|
|
831
|
+
if (!d || S.readyState !== "open") {
|
|
828
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"), {
|
|
829
|
-
streamId:
|
|
833
|
+
streamId: C
|
|
830
834
|
});
|
|
831
835
|
return;
|
|
832
836
|
}
|
|
833
837
|
try {
|
|
834
|
-
|
|
835
|
-
} catch (
|
|
836
|
-
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 });
|
|
837
841
|
}
|
|
838
842
|
},
|
|
839
843
|
/**
|
|
@@ -843,21 +847,22 @@ async function yt(e, t, { debug: n = !1, callbacks: r, auth: i, baseURL: o = G,
|
|
|
843
847
|
/**
|
|
844
848
|
* Id of current RTC stream
|
|
845
849
|
*/
|
|
846
|
-
streamId:
|
|
847
|
-
streamType:
|
|
848
|
-
interruptAvailable: _ ?? !1
|
|
850
|
+
streamId: C,
|
|
851
|
+
streamType: T,
|
|
852
|
+
interruptAvailable: _ ?? !1,
|
|
853
|
+
triggersAvailable: v ?? !1
|
|
849
854
|
};
|
|
850
855
|
}
|
|
851
|
-
const
|
|
852
|
-
async function
|
|
856
|
+
const kt = (e) => e.presenter.type === de.Expressive;
|
|
857
|
+
async function Dt(e, t, n) {
|
|
853
858
|
const r = e.id;
|
|
854
|
-
if (
|
|
855
|
-
const { createLiveKitStreamingManager: i } = await import("./livekit-manager-
|
|
859
|
+
if (kt(e)) {
|
|
860
|
+
const { createLiveKitStreamingManager: i } = await import("./livekit-manager-DZ_BAT5P.js");
|
|
856
861
|
return i(r, t, n);
|
|
857
862
|
} else
|
|
858
|
-
return
|
|
863
|
+
return vt(r, t, n);
|
|
859
864
|
}
|
|
860
|
-
function
|
|
865
|
+
function Ct(e) {
|
|
861
866
|
const { streamOptions: t } = e ?? {};
|
|
862
867
|
return {
|
|
863
868
|
output_resolution: t == null ? void 0 : t.outputResolution,
|
|
@@ -867,10 +872,10 @@ function Dt(e) {
|
|
|
867
872
|
fluent: t == null ? void 0 : t.fluent
|
|
868
873
|
};
|
|
869
874
|
}
|
|
870
|
-
function Ct(e, t, n, r, i) {
|
|
871
|
-
i === N.Fluent ? Rt(e, t, n, r, i) : It(e, t, n, r, i);
|
|
872
|
-
}
|
|
873
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) {
|
|
874
879
|
e === w.Start ? r.track("stream-session", { event: "start", "stream-type": i }) : e === w.Stop && r.track("stream-session", {
|
|
875
880
|
event: "stop",
|
|
876
881
|
is_greenscreen: t.presenter.type === "clip" && t.presenter.is_greenscreen,
|
|
@@ -879,12 +884,12 @@ function Rt(e, t, n, r, i) {
|
|
|
879
884
|
...n
|
|
880
885
|
});
|
|
881
886
|
}
|
|
882
|
-
function
|
|
883
|
-
|
|
887
|
+
function It(e, t, n, r) {
|
|
888
|
+
$.get() <= 0 || (e === w.Start ? n.linkTrack(
|
|
884
889
|
"agent-video",
|
|
885
|
-
{ event: "start", latency:
|
|
890
|
+
{ event: "start", latency: $.get(!0), "stream-type": r },
|
|
886
891
|
"start",
|
|
887
|
-
[
|
|
892
|
+
[P.StreamVideoCreated]
|
|
888
893
|
) : e === w.Stop && n.linkTrack(
|
|
889
894
|
"agent-video",
|
|
890
895
|
{
|
|
@@ -894,15 +899,15 @@ function St(e, t, n, r) {
|
|
|
894
899
|
"stream-type": r
|
|
895
900
|
},
|
|
896
901
|
"done",
|
|
897
|
-
[
|
|
902
|
+
[P.StreamVideoDone]
|
|
898
903
|
));
|
|
899
904
|
}
|
|
900
|
-
function
|
|
901
|
-
|
|
905
|
+
function Et(e, t, n, r, i) {
|
|
906
|
+
$.get() <= 0 || (e === w.Start ? r.linkTrack(
|
|
902
907
|
"agent-video",
|
|
903
|
-
{ event: "start", latency:
|
|
908
|
+
{ event: "start", latency: $.get(!0), "stream-type": i },
|
|
904
909
|
"start",
|
|
905
|
-
[
|
|
910
|
+
[P.StreamVideoCreated]
|
|
906
911
|
) : e === w.Stop && r.linkTrack(
|
|
907
912
|
"agent-video",
|
|
908
913
|
{
|
|
@@ -913,25 +918,25 @@ function It(e, t, n, r, i) {
|
|
|
913
918
|
...n
|
|
914
919
|
},
|
|
915
920
|
"done",
|
|
916
|
-
[
|
|
921
|
+
[P.StreamVideoDone]
|
|
917
922
|
));
|
|
918
923
|
}
|
|
919
|
-
function
|
|
920
|
-
return
|
|
924
|
+
function Mt(e, t, n) {
|
|
925
|
+
return $.reset(), new Promise(async (r, i) => {
|
|
921
926
|
try {
|
|
922
927
|
let o;
|
|
923
|
-
o = await
|
|
928
|
+
o = await Dt(e, Ct(t), {
|
|
924
929
|
...t,
|
|
925
930
|
analytics: n,
|
|
926
931
|
callbacks: {
|
|
927
932
|
...t.callbacks,
|
|
928
933
|
onConnectionStateChange: (c) => {
|
|
929
934
|
var a, s;
|
|
930
|
-
(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);
|
|
931
936
|
},
|
|
932
937
|
onVideoStateChange: (c, a) => {
|
|
933
938
|
var s, d;
|
|
934
|
-
(d = (s = t.callbacks).onVideoStateChange) == null || d.call(s, c),
|
|
939
|
+
(d = (s = t.callbacks).onVideoStateChange) == null || d.call(s, c), Rt(
|
|
935
940
|
c,
|
|
936
941
|
e,
|
|
937
942
|
a,
|
|
@@ -941,7 +946,7 @@ function Et(e, t, n) {
|
|
|
941
946
|
},
|
|
942
947
|
onAgentActivityStateChange: (c) => {
|
|
943
948
|
var a, s;
|
|
944
|
-
(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(
|
|
945
950
|
c === O.Talking ? w.Start : w.Stop,
|
|
946
951
|
e,
|
|
947
952
|
n,
|
|
@@ -955,27 +960,28 @@ function Et(e, t, n) {
|
|
|
955
960
|
}
|
|
956
961
|
});
|
|
957
962
|
}
|
|
958
|
-
async function
|
|
959
|
-
var
|
|
960
|
-
const o =
|
|
961
|
-
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 };
|
|
962
967
|
}
|
|
963
|
-
async function
|
|
964
|
-
var
|
|
968
|
+
async function At(e, t) {
|
|
969
|
+
var W, C, U;
|
|
965
970
|
let n = !0, r = null;
|
|
966
|
-
const i = t.mixpanelKey || ze, o = t.wsURL ||
|
|
971
|
+
const i = t.mixpanelKey || ze, o = t.wsURL || xe, c = t.baseURL || ee, a = {
|
|
967
972
|
messages: [],
|
|
968
973
|
chatMode: t.mode || E.Functional
|
|
969
|
-
}, s =
|
|
974
|
+
}, s = Oe({
|
|
970
975
|
token: i,
|
|
971
976
|
agentId: e,
|
|
972
977
|
isEnabled: t.enableAnalitics,
|
|
973
|
-
distinctId: t.distinctId
|
|
978
|
+
distinctId: t.distinctId,
|
|
979
|
+
mixpanelAdditionalProperties: t.mixpanelAdditionalProperties
|
|
974
980
|
});
|
|
975
981
|
s.track("agent-sdk", { event: "init" });
|
|
976
|
-
const d =
|
|
977
|
-
s.enrich(
|
|
978
|
-
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(
|
|
979
985
|
s,
|
|
980
986
|
a,
|
|
981
987
|
t,
|
|
@@ -985,47 +991,47 @@ async function jt(e, t) {
|
|
|
985
991
|
return (u = a.socketManager) == null ? void 0 : u.disconnect();
|
|
986
992
|
}
|
|
987
993
|
);
|
|
988
|
-
a.messages =
|
|
989
|
-
const
|
|
994
|
+
a.messages = Xe(t.initialMessages), (C = (W = t.callbacks).onNewMessage) == null || C.call(W, [...a.messages], "answer");
|
|
995
|
+
const j = (u) => {
|
|
990
996
|
r = u;
|
|
991
997
|
};
|
|
992
|
-
s.track("agent-sdk", { event: "loaded", ...
|
|
998
|
+
s.track("agent-sdk", { event: "loaded", ...Ke(l) });
|
|
993
999
|
async function b(u) {
|
|
994
|
-
var
|
|
995
|
-
(
|
|
996
|
-
const h = t.mode === E.DirectPlayback ? Promise.resolve(void 0) :
|
|
997
|
-
() =>
|
|
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(
|
|
998
1004
|
l,
|
|
999
|
-
{ ...t, callbacks: { ...t.callbacks, onVideoIdChange:
|
|
1005
|
+
{ ...t, callbacks: { ...t.callbacks, onVideoIdChange: j } },
|
|
1000
1006
|
d,
|
|
1001
1007
|
s,
|
|
1002
1008
|
a.chat
|
|
1003
1009
|
),
|
|
1004
1010
|
{
|
|
1005
1011
|
limit: 3,
|
|
1006
|
-
timeout:
|
|
1012
|
+
timeout: Be,
|
|
1007
1013
|
timeoutErrorMessage: "Timeout initializing the stream",
|
|
1008
1014
|
// Retry on all errors except for connection errors and rate limit errors, these are already handled in client level.
|
|
1009
|
-
shouldRetryFn: (
|
|
1015
|
+
shouldRetryFn: (B) => (B == null ? void 0 : B.message) !== "Could not connect" && B.status !== 429,
|
|
1010
1016
|
delayMs: 1e3
|
|
1011
1017
|
}
|
|
1012
|
-
).catch((
|
|
1013
|
-
var
|
|
1014
|
-
throw K(E.Maintenance), (
|
|
1015
|
-
}), [_, { streamingManager:
|
|
1016
|
-
|
|
1017
|
-
chatId:
|
|
1018
|
-
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,
|
|
1019
1025
|
mode: a.chatMode
|
|
1020
|
-
}), K((
|
|
1026
|
+
}), K((f == null ? void 0 : f.chat_mode) ?? t.mode ?? E.Functional);
|
|
1021
1027
|
}
|
|
1022
|
-
async function
|
|
1028
|
+
async function z() {
|
|
1023
1029
|
var u, h, p, _;
|
|
1024
|
-
(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);
|
|
1025
1031
|
}
|
|
1026
1032
|
async function K(u) {
|
|
1027
1033
|
var h, p;
|
|
1028
|
-
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));
|
|
1029
1035
|
}
|
|
1030
1036
|
return {
|
|
1031
1037
|
agent: l,
|
|
@@ -1037,6 +1043,10 @@ async function jt(e, t) {
|
|
|
1037
1043
|
var u;
|
|
1038
1044
|
return ((u = a.streamingManager) == null ? void 0 : u.interruptAvailable) ?? !1;
|
|
1039
1045
|
},
|
|
1046
|
+
getIsTriggersAvailable: () => {
|
|
1047
|
+
var u;
|
|
1048
|
+
return ((u = a.streamingManager) == null ? void 0 : u.triggersAvailable) ?? !1;
|
|
1049
|
+
},
|
|
1040
1050
|
starterMessages: ((U = l.knowledge) == null ? void 0 : U.starter_message) || [],
|
|
1041
1051
|
getSTTToken: () => d.getSTTToken(l.id),
|
|
1042
1052
|
changeMode: K,
|
|
@@ -1048,21 +1058,21 @@ async function jt(e, t) {
|
|
|
1048
1058
|
});
|
|
1049
1059
|
},
|
|
1050
1060
|
async reconnect() {
|
|
1051
|
-
await
|
|
1061
|
+
await z(), await b(!1), s.track("agent-chat", {
|
|
1052
1062
|
event: "reconnect",
|
|
1053
1063
|
mode: a.chatMode
|
|
1054
1064
|
});
|
|
1055
1065
|
},
|
|
1056
1066
|
async disconnect() {
|
|
1057
|
-
await
|
|
1067
|
+
await z(), s.track("agent-chat", {
|
|
1058
1068
|
event: "disconnect",
|
|
1059
1069
|
mode: a.chatMode
|
|
1060
1070
|
});
|
|
1061
1071
|
},
|
|
1062
1072
|
async chat(u) {
|
|
1063
|
-
var
|
|
1073
|
+
var v, f, S, T, L;
|
|
1064
1074
|
const h = () => {
|
|
1065
|
-
if (
|
|
1075
|
+
if (ue(t.mode))
|
|
1066
1076
|
throw new H(`${t.mode} is enabled, chat is disabled`);
|
|
1067
1077
|
if (u.length >= 800)
|
|
1068
1078
|
throw new H("Message cannot be more than 800 characters");
|
|
@@ -1077,47 +1087,47 @@ async function jt(e, t) {
|
|
|
1077
1087
|
throw new H("Chat is not initialized");
|
|
1078
1088
|
}
|
|
1079
1089
|
}, p = async () => {
|
|
1080
|
-
var
|
|
1090
|
+
var D, I;
|
|
1081
1091
|
if (!a.chat) {
|
|
1082
|
-
const
|
|
1092
|
+
const k = await ve(
|
|
1083
1093
|
l,
|
|
1084
1094
|
d,
|
|
1085
1095
|
s,
|
|
1086
1096
|
a.chatMode,
|
|
1087
1097
|
t.persistentChat
|
|
1088
1098
|
);
|
|
1089
|
-
if (!
|
|
1090
|
-
throw new
|
|
1091
|
-
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);
|
|
1092
1102
|
}
|
|
1093
1103
|
return a.chat.id;
|
|
1094
|
-
}, _ = async (
|
|
1104
|
+
}, _ = async (D, I) => ne(
|
|
1095
1105
|
() => {
|
|
1096
|
-
var
|
|
1106
|
+
var k, x;
|
|
1097
1107
|
return d.chat(
|
|
1098
1108
|
l.id,
|
|
1099
1109
|
I,
|
|
1100
1110
|
{
|
|
1101
1111
|
chatMode: a.chatMode,
|
|
1102
|
-
streamId: (
|
|
1103
|
-
sessionId: (
|
|
1104
|
-
messages:
|
|
1112
|
+
streamId: (k = a.streamingManager) == null ? void 0 : k.streamId,
|
|
1113
|
+
sessionId: (x = a.streamingManager) == null ? void 0 : x.sessionId,
|
|
1114
|
+
messages: D.map(({ matches: B, ...F }) => F)
|
|
1105
1115
|
},
|
|
1106
1116
|
{
|
|
1107
|
-
...
|
|
1117
|
+
...ye(a.chatMode),
|
|
1108
1118
|
skipErrorHandler: !0
|
|
1109
1119
|
}
|
|
1110
1120
|
);
|
|
1111
1121
|
},
|
|
1112
1122
|
{
|
|
1113
1123
|
limit: 2,
|
|
1114
|
-
shouldRetryFn: (
|
|
1115
|
-
var
|
|
1116
|
-
const
|
|
1117
|
-
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;
|
|
1118
1128
|
},
|
|
1119
1129
|
onRetry: async () => {
|
|
1120
|
-
await
|
|
1130
|
+
await z(), await b(!1);
|
|
1121
1131
|
}
|
|
1122
1132
|
}
|
|
1123
1133
|
);
|
|
@@ -1126,9 +1136,9 @@ async function jt(e, t) {
|
|
|
1126
1136
|
id: V(),
|
|
1127
1137
|
role: "user",
|
|
1128
1138
|
content: u,
|
|
1129
|
-
created_at: new Date(
|
|
1130
|
-
}), (
|
|
1131
|
-
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);
|
|
1132
1142
|
return a.messages.push({
|
|
1133
1143
|
id: V(),
|
|
1134
1144
|
role: "assistant",
|
|
@@ -1139,40 +1149,40 @@ async function jt(e, t) {
|
|
|
1139
1149
|
}), s.track("agent-message-send", {
|
|
1140
1150
|
event: "success",
|
|
1141
1151
|
messages: a.messages.length + 1
|
|
1142
|
-
}), I.result && ((
|
|
1143
|
-
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),
|
|
1144
1154
|
messages: a.messages.length
|
|
1145
1155
|
})), I;
|
|
1146
|
-
} catch (
|
|
1147
|
-
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", {
|
|
1148
1158
|
event: "error",
|
|
1149
1159
|
messages: a.messages.length
|
|
1150
|
-
}),
|
|
1160
|
+
}), D;
|
|
1151
1161
|
}
|
|
1152
1162
|
},
|
|
1153
1163
|
rate(u, h, p) {
|
|
1154
|
-
var
|
|
1155
|
-
const _ = a.messages.find((
|
|
1164
|
+
var f, S, T, L;
|
|
1165
|
+
const _ = a.messages.find((D) => D.id === u);
|
|
1156
1166
|
if (a.chat) {
|
|
1157
1167
|
if (!_)
|
|
1158
1168
|
throw new Error("Message not found");
|
|
1159
1169
|
} else throw new Error("Chat is not initialized");
|
|
1160
|
-
const
|
|
1170
|
+
const v = ((f = _.matches) == null ? void 0 : f.map((D) => [D.document_id, D.id])) ?? [];
|
|
1161
1171
|
return s.track("agent-rate", {
|
|
1162
1172
|
event: p ? "update" : "create",
|
|
1163
1173
|
thumb: h === 1 ? "up" : "down",
|
|
1164
|
-
knowledge_id: ((
|
|
1165
|
-
matches:
|
|
1174
|
+
knowledge_id: ((S = l.knowledge) == null ? void 0 : S.id) ?? "",
|
|
1175
|
+
matches: v,
|
|
1166
1176
|
score: h
|
|
1167
1177
|
}), p ? d.updateRating(l.id, a.chat.id, p, {
|
|
1168
|
-
knowledge_id: ((
|
|
1178
|
+
knowledge_id: ((T = l.knowledge) == null ? void 0 : T.id) ?? "",
|
|
1169
1179
|
message_id: u,
|
|
1170
|
-
matches:
|
|
1180
|
+
matches: v,
|
|
1171
1181
|
score: h
|
|
1172
1182
|
}) : d.createRating(l.id, a.chat.id, {
|
|
1173
|
-
knowledge_id: ((
|
|
1183
|
+
knowledge_id: ((L = l.knowledge) == null ? void 0 : L.id) ?? "",
|
|
1174
1184
|
message_id: u,
|
|
1175
|
-
matches:
|
|
1185
|
+
matches: v,
|
|
1176
1186
|
score: h
|
|
1177
1187
|
});
|
|
1178
1188
|
},
|
|
@@ -1182,7 +1192,7 @@ async function jt(e, t) {
|
|
|
1182
1192
|
return s.track("agent-rate-delete", { type: "text" }), d.deleteRating(l.id, a.chat.id, u);
|
|
1183
1193
|
},
|
|
1184
1194
|
async speak(u) {
|
|
1185
|
-
var
|
|
1195
|
+
var v, f, S;
|
|
1186
1196
|
function h() {
|
|
1187
1197
|
if (typeof u == "string") {
|
|
1188
1198
|
if (!l.presenter.voice)
|
|
@@ -1207,12 +1217,12 @@ async function jt(e, t) {
|
|
|
1207
1217
|
return u;
|
|
1208
1218
|
}
|
|
1209
1219
|
const p = h();
|
|
1210
|
-
if (s.track("agent-speak", p),
|
|
1220
|
+
if (s.track("agent-speak", p), $.update(), a.messages && p.type === "text" && (a.messages.push({
|
|
1211
1221
|
id: V(),
|
|
1212
1222
|
role: "assistant",
|
|
1213
1223
|
content: p.input,
|
|
1214
|
-
created_at: new Date(
|
|
1215
|
-
}), (
|
|
1224
|
+
created_at: new Date($.get(!0)).toISOString()
|
|
1225
|
+
}), (f = (v = t.callbacks).onNewMessage) == null || f.call(v, [...a.messages], "answer")), Fe(a.chatMode))
|
|
1216
1226
|
return {
|
|
1217
1227
|
duration: 0,
|
|
1218
1228
|
video_id: "",
|
|
@@ -1222,53 +1232,53 @@ async function jt(e, t) {
|
|
|
1222
1232
|
throw new Error("Please connect to the agent first");
|
|
1223
1233
|
return a.streamingManager.speak({
|
|
1224
1234
|
script: p,
|
|
1225
|
-
metadata: { chat_id: (
|
|
1235
|
+
metadata: { chat_id: (S = a.chat) == null ? void 0 : S.id, agent_id: l.id }
|
|
1226
1236
|
});
|
|
1227
1237
|
},
|
|
1228
1238
|
async interrupt({ type: u }) {
|
|
1229
|
-
var p, _,
|
|
1230
|
-
|
|
1239
|
+
var p, _, v;
|
|
1240
|
+
Ye(a.streamingManager, (p = a.streamingManager) == null ? void 0 : p.streamType, r);
|
|
1231
1241
|
const h = a.messages[a.messages.length - 1];
|
|
1232
1242
|
s.track("agent-video-interrupt", {
|
|
1233
1243
|
type: u || "click",
|
|
1234
|
-
video_duration_to_interrupt:
|
|
1235
|
-
message_duration_to_interrupt:
|
|
1236
|
-
}), 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);
|
|
1237
1247
|
}
|
|
1238
1248
|
};
|
|
1239
1249
|
}
|
|
1240
1250
|
function bt(e, t, n) {
|
|
1241
|
-
const { getById: r } =
|
|
1251
|
+
const { getById: r } = he(t, n || ee);
|
|
1242
1252
|
return r(e);
|
|
1243
1253
|
}
|
|
1244
1254
|
export {
|
|
1245
1255
|
O as A,
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1256
|
+
R as C,
|
|
1257
|
+
Ae as D,
|
|
1258
|
+
je as K,
|
|
1259
|
+
Ee as P,
|
|
1260
|
+
_e as R,
|
|
1261
|
+
J as S,
|
|
1252
1262
|
be as T,
|
|
1253
|
-
|
|
1263
|
+
Ie as U,
|
|
1254
1264
|
H as V,
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1265
|
+
Se as W,
|
|
1266
|
+
it as a,
|
|
1267
|
+
G as b,
|
|
1268
|
+
ge as c,
|
|
1259
1269
|
w as d,
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1270
|
+
P as e,
|
|
1271
|
+
ee as f,
|
|
1272
|
+
Ce as g,
|
|
1273
|
+
Re as h,
|
|
1274
|
+
At as i,
|
|
1265
1275
|
bt as j,
|
|
1266
|
-
|
|
1276
|
+
Me as k,
|
|
1267
1277
|
E as l,
|
|
1268
1278
|
q as m,
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1279
|
+
Te as n,
|
|
1280
|
+
de as o,
|
|
1281
|
+
jt as p,
|
|
1282
|
+
Pe as q,
|
|
1283
|
+
Le as r
|
|
1274
1284
|
};
|