@d-id/client-sdk 1.1.47 → 1.1.48-staging.213
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.js +637 -636
- package/dist/index.umd.cjs +5 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var rt = Object.defineProperty;
|
|
2
|
+
var it = (e, t, i) => t in e ? rt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
|
|
3
|
+
var ge = (e, t, i) => it(e, typeof t != "symbol" ? t + "" : t, i);
|
|
4
4
|
class Se extends Error {
|
|
5
5
|
constructor({ kind: i, description: r, error: o }) {
|
|
6
6
|
super(JSON.stringify({ kind: i, description: r }));
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
ge(this, "kind");
|
|
8
|
+
ge(this, "description");
|
|
9
|
+
ge(this, "error");
|
|
10
10
|
this.kind = i, this.description = r, this.error = o;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
class
|
|
13
|
+
class at extends Se {
|
|
14
14
|
constructor(t, i) {
|
|
15
15
|
super({
|
|
16
16
|
kind: "ChatCreationFailed",
|
|
@@ -18,25 +18,25 @@ class it extends Se {
|
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
class
|
|
21
|
+
class ot extends Se {
|
|
22
22
|
constructor(t) {
|
|
23
23
|
super({ kind: "ChatModeDowngraded", description: `Chat mode downgraded to ${t}` });
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
class
|
|
26
|
+
class fe extends Se {
|
|
27
27
|
constructor(i, r) {
|
|
28
28
|
super({ kind: "ValidationError", description: i });
|
|
29
|
-
|
|
29
|
+
ge(this, "key");
|
|
30
30
|
this.key = r;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
class
|
|
33
|
+
class st extends Se {
|
|
34
34
|
constructor(t) {
|
|
35
35
|
super({ kind: "WSError", description: t });
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
var
|
|
39
|
-
const
|
|
38
|
+
var ct = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(ct || {}), dt = /* @__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))(dt || {}), ut = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(ut || {}), lt = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(lt || {}), x = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e.Off = "Off", e))(x || {}), X = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Transcribe = "transcribe", e.Complete = "done", e))(X || {}), ft = /* @__PURE__ */ ((e) => (e.KnowledgeProcessing = "knowledge/processing", e.KnowledgeIndexing = "knowledge/indexing", e.KnowledgeFailed = "knowledge/error", e.KnowledgeDone = "knowledge/done", e))(ft || {}), mt = /* @__PURE__ */ ((e) => (e.Knowledge = "knowledge", e.Document = "document", e.Record = "record", e))(mt || {}), gt = /* @__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))(gt || {}), Oe = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e.Expressive = "expressive", e))(Oe || {});
|
|
39
|
+
const kn = (e) => {
|
|
40
40
|
switch (e) {
|
|
41
41
|
case "clip":
|
|
42
42
|
return "clip";
|
|
@@ -48,13 +48,13 @@ const Sn = (e) => {
|
|
|
48
48
|
throw new Error(`Unknown video type: ${e}`);
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
var
|
|
52
|
-
const
|
|
53
|
-
},
|
|
51
|
+
var C = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(C || {}), ne = /* @__PURE__ */ ((e) => (e.Strong = "STRONG", e.Weak = "WEAK", e.Unknown = "UNKNOWN", e))(ne || {}), O = /* @__PURE__ */ ((e) => (e.Idle = "IDLE", e.Loading = "LOADING", e.Talking = "TALKING", e))(O || {}), L = /* @__PURE__ */ ((e) => (e.ChatAnswer = "chat/answer", e.ChatPartial = "chat/partial", e.ChatAudioTranscribed = "chat/audio-transcribed", 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))(L || {}), T = /* @__PURE__ */ ((e) => (e.New = "new", e.Fail = "fail", e.Connected = "connected", e.Connecting = "connecting", e.Closed = "closed", e.Completed = "completed", e.Disconnecting = "disconnecting", e.Disconnected = "disconnected", e))(T || {}), re = /* @__PURE__ */ ((e) => (e.Legacy = "legacy", e.Fluent = "fluent", e))(re || {}), ke = /* @__PURE__ */ ((e) => (e.Livekit = "livekit", e))(ke || {}), ht = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.AzureOpenAi = "azure-openai", e.Microsoft = "microsoft", e.Afflorithmics = "afflorithmics", e.Elevenlabs = "elevenlabs", e))(ht || {}), pt = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e))(pt || {});
|
|
52
|
+
const wt = 45 * 1e3, yt = "X-Playground-Chat", pe = "https://api.d-id.com", vt = "wss://notifications.d-id.com", Ct = "79f81a83a67430be2bc0fd61042b8faa", St = (...e) => {
|
|
53
|
+
}, He = (e) => new Promise((t) => setTimeout(t, e)), me = (e = 16) => {
|
|
54
54
|
const t = new Uint8Array(e);
|
|
55
55
|
return window.crypto.getRandomValues(t), Array.from(t, (i) => i.toString(16).padStart(2, "0")).join("").slice(0, 13);
|
|
56
|
-
},
|
|
57
|
-
function
|
|
56
|
+
}, qe = (e) => e.type === "clip" && e.presenter_id.startsWith("v2_") ? "clip_v2" : e.type, _e = (e) => e === Oe.Expressive, kt = (e) => [x.TextOnly, x.Playground, x.Maintenance].includes(e), Qe = (e) => e && [x.DirectPlayback, x.Off].includes(e);
|
|
57
|
+
function Rt(e, t) {
|
|
58
58
|
let i;
|
|
59
59
|
return {
|
|
60
60
|
promise: new Promise((o, a) => {
|
|
@@ -63,7 +63,7 @@ function kt(e, t) {
|
|
|
63
63
|
clear: () => clearTimeout(i)
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
|
-
async function
|
|
66
|
+
async function De(e, t) {
|
|
67
67
|
const i = {
|
|
68
68
|
limit: (t == null ? void 0 : t.limit) ?? 3,
|
|
69
69
|
delayMs: (t == null ? void 0 : t.delayMs) ?? 0,
|
|
@@ -78,12 +78,12 @@ async function Me(e, t) {
|
|
|
78
78
|
try {
|
|
79
79
|
if (!i.timeout)
|
|
80
80
|
return await e();
|
|
81
|
-
const { promise: a, clear: s } =
|
|
81
|
+
const { promise: a, clear: s } = Rt(i.timeout, i.timeoutErrorMessage), d = e().finally(s);
|
|
82
82
|
return await Promise.race([d, a]);
|
|
83
83
|
} catch (a) {
|
|
84
84
|
if (r = a, !i.shouldRetryFn(a) || o >= i.limit)
|
|
85
85
|
throw a;
|
|
86
|
-
await
|
|
86
|
+
await He(i.delayMs), i.onRetry(a);
|
|
87
87
|
}
|
|
88
88
|
throw r;
|
|
89
89
|
}
|
|
@@ -92,43 +92,43 @@ function Ee(e) {
|
|
|
92
92
|
return window.localStorage.setItem("did_external_key_id", e), e;
|
|
93
93
|
let t = window.localStorage.getItem("did_external_key_id");
|
|
94
94
|
if (!t) {
|
|
95
|
-
let i =
|
|
95
|
+
let i = me();
|
|
96
96
|
window.localStorage.setItem("did_external_key_id", i), t = i;
|
|
97
97
|
}
|
|
98
98
|
return t;
|
|
99
99
|
}
|
|
100
|
-
let
|
|
101
|
-
function
|
|
100
|
+
let Dt = me();
|
|
101
|
+
function Xe(e, t) {
|
|
102
102
|
if (e.type === "bearer")
|
|
103
103
|
return `Bearer ${e.token}`;
|
|
104
104
|
if (e.type === "basic")
|
|
105
105
|
return `Basic ${btoa(`${e.username}:${e.password}`)}`;
|
|
106
106
|
if (e.type === "key")
|
|
107
|
-
return `Client-Key ${e.clientKey}.${Ee(t)}_${
|
|
107
|
+
return `Client-Key ${e.clientKey}.${Ee(t)}_${Dt}`;
|
|
108
108
|
throw new Error(`Unknown auth type: ${e}`);
|
|
109
109
|
}
|
|
110
|
-
const
|
|
110
|
+
const Et = (e) => De(e, {
|
|
111
111
|
limit: 3,
|
|
112
112
|
delayMs: 1e3,
|
|
113
113
|
timeout: 0,
|
|
114
114
|
shouldRetryFn: (t) => t.status === 429
|
|
115
115
|
});
|
|
116
|
-
function
|
|
116
|
+
function Ae(e, t = pe, i, r) {
|
|
117
117
|
const o = async (a, s) => {
|
|
118
|
-
const { skipErrorHandler: d, ...n } = s || {}, c = await
|
|
118
|
+
const { skipErrorHandler: d, ...n } = s || {}, c = await Et(
|
|
119
119
|
() => fetch(t + (a != null && a.startsWith("/") ? a : `/${a}`), {
|
|
120
120
|
...n,
|
|
121
121
|
headers: {
|
|
122
122
|
...n.headers,
|
|
123
|
-
Authorization:
|
|
123
|
+
Authorization: Xe(e, r),
|
|
124
124
|
"Content-Type": "application/json"
|
|
125
125
|
}
|
|
126
126
|
})
|
|
127
127
|
);
|
|
128
128
|
if (!c.ok) {
|
|
129
|
-
let
|
|
130
|
-
const
|
|
131
|
-
throw i && !d && i(
|
|
129
|
+
let g = await c.text().catch(() => `Failed to fetch with status ${c.status}`);
|
|
130
|
+
const w = new Error(g);
|
|
131
|
+
throw i && !d && i(w, { url: a, options: n, headers: c.headers }), w;
|
|
132
132
|
}
|
|
133
133
|
return c.json();
|
|
134
134
|
};
|
|
@@ -147,8 +147,8 @@ function Pe(e, t = he, i, r) {
|
|
|
147
147
|
}
|
|
148
148
|
};
|
|
149
149
|
}
|
|
150
|
-
function Mt(e, t =
|
|
151
|
-
const o =
|
|
150
|
+
function Mt(e, t = pe, i, r) {
|
|
151
|
+
const o = Ae(e, `${t}/agents`, i, r);
|
|
152
152
|
return {
|
|
153
153
|
create(a, s) {
|
|
154
154
|
return o.post("/", a, s);
|
|
@@ -185,7 +185,7 @@ function Mt(e, t = he, i, r) {
|
|
|
185
185
|
}
|
|
186
186
|
};
|
|
187
187
|
}
|
|
188
|
-
function
|
|
188
|
+
function It(e) {
|
|
189
189
|
var o, a, s, d;
|
|
190
190
|
const t = () => /Mobi|Android/i.test(navigator.userAgent) ? "Mobile" : "Desktop", i = () => {
|
|
191
191
|
const n = navigator.platform;
|
|
@@ -196,18 +196,18 @@ function Et(e) {
|
|
|
196
196
|
isMobile: `${t() == "Mobile"}`,
|
|
197
197
|
browser: navigator.userAgent,
|
|
198
198
|
origin: window.location.origin,
|
|
199
|
-
agentType:
|
|
199
|
+
agentType: qe(r),
|
|
200
200
|
agentVoice: {
|
|
201
201
|
voiceId: (a = (o = e.presenter) == null ? void 0 : o.voice) == null ? void 0 : a.voice_id,
|
|
202
202
|
provider: (d = (s = e.presenter) == null ? void 0 : s.voice) == null ? void 0 : d.type
|
|
203
203
|
}
|
|
204
204
|
};
|
|
205
205
|
}
|
|
206
|
-
function
|
|
206
|
+
function Tt(e) {
|
|
207
207
|
var i, r, o, a, s, d;
|
|
208
208
|
const t = (i = e.llm) == null ? void 0 : i.prompt_customization;
|
|
209
209
|
return {
|
|
210
|
-
agentType:
|
|
210
|
+
agentType: qe(e.presenter),
|
|
211
211
|
owner_id: e.owner_id ?? "",
|
|
212
212
|
promptVersion: (r = e.llm) == null ? void 0 : r.prompt_version,
|
|
213
213
|
behavior: {
|
|
@@ -226,25 +226,24 @@ function It(e) {
|
|
|
226
226
|
...e.access === "public" ? { from: "agent-template" } : {}
|
|
227
227
|
};
|
|
228
228
|
}
|
|
229
|
-
const
|
|
230
|
-
function
|
|
231
|
-
var n, c,
|
|
229
|
+
const _t = (e) => e.reduce((t, i) => t + i, 0), ze = (e) => _t(e) / e.length;
|
|
230
|
+
function At(e, t, i) {
|
|
231
|
+
var n, c, g;
|
|
232
232
|
const { event: r, ...o } = e, { template: a } = (t == null ? void 0 : t.llm) || {}, { language: s } = ((n = t == null ? void 0 : t.presenter) == null ? void 0 : n.voice) || {};
|
|
233
233
|
return {
|
|
234
234
|
...o,
|
|
235
235
|
llm: { ...o.llm, template: a },
|
|
236
236
|
script: { ...o.script, provider: { ...(c = o == null ? void 0 : o.script) == null ? void 0 : c.provider, language: s } },
|
|
237
|
-
stitch: (t == null ? void 0 : t.presenter.type) === "talk" ? (
|
|
237
|
+
stitch: (t == null ? void 0 : t.presenter.type) === "talk" ? (g = t == null ? void 0 : t.presenter) == null ? void 0 : g.stitch : void 0,
|
|
238
238
|
...i
|
|
239
239
|
};
|
|
240
240
|
}
|
|
241
|
-
function
|
|
241
|
+
function Ke(e) {
|
|
242
242
|
"requestIdleCallback" in window ? requestIdleCallback(e, { timeout: 2e3 }) : setTimeout(e, 0);
|
|
243
243
|
}
|
|
244
|
-
|
|
245
|
-
const At = "https://api-js.mixpanel.com/track/?verbose=1&ip=1";
|
|
244
|
+
const Lt = "https://api-js.mixpanel.com/track/?verbose=1&ip=1";
|
|
246
245
|
function Pt(e) {
|
|
247
|
-
const t = window != null && window.hasOwnProperty("DID_AGENTS_API") ? "agents-ui" : "agents-sdk";
|
|
246
|
+
const t = window != null && window.hasOwnProperty("DID_AGENTS_API") ? "agents-ui" : "agents-sdk", i = {};
|
|
248
247
|
return {
|
|
249
248
|
token: e.token || "testKey",
|
|
250
249
|
distinct_id: Ee(e.externalId),
|
|
@@ -254,14 +253,14 @@ function Pt(e) {
|
|
|
254
253
|
...e.mixpanelAdditionalProperties || {}
|
|
255
254
|
},
|
|
256
255
|
isEnabled: e.isEnabled ?? !0,
|
|
257
|
-
getRandom:
|
|
258
|
-
enrich(
|
|
259
|
-
this.additionalProperties = { ...this.additionalProperties, ...
|
|
256
|
+
getRandom: me,
|
|
257
|
+
enrich(r) {
|
|
258
|
+
this.additionalProperties = { ...this.additionalProperties, ...r };
|
|
260
259
|
},
|
|
261
|
-
async track(
|
|
260
|
+
async track(r, o, a) {
|
|
262
261
|
if (!this.isEnabled)
|
|
263
262
|
return Promise.resolve();
|
|
264
|
-
const { audioPath:
|
|
263
|
+
const { audioPath: s, ...d } = o || {}, n = a || Date.now(), c = {
|
|
265
264
|
method: "POST",
|
|
266
265
|
headers: {
|
|
267
266
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -269,14 +268,14 @@ function Pt(e) {
|
|
|
269
268
|
body: new URLSearchParams({
|
|
270
269
|
data: JSON.stringify([
|
|
271
270
|
{
|
|
272
|
-
event:
|
|
271
|
+
event: r,
|
|
273
272
|
properties: {
|
|
274
273
|
...this.additionalProperties,
|
|
275
|
-
...
|
|
274
|
+
...d,
|
|
276
275
|
agentId: this.agentId,
|
|
277
276
|
source: t,
|
|
278
277
|
token: this.token,
|
|
279
|
-
time:
|
|
278
|
+
time: n,
|
|
280
279
|
$insert_id: this.getRandom(),
|
|
281
280
|
origin: window.location.href,
|
|
282
281
|
"Screen Height": window.screen.height || window.innerWidth,
|
|
@@ -287,22 +286,19 @@ function Pt(e) {
|
|
|
287
286
|
])
|
|
288
287
|
})
|
|
289
288
|
};
|
|
290
|
-
return fetch(
|
|
291
|
-
...n,
|
|
292
|
-
keepalive: !0
|
|
293
|
-
}).catch((c) => console.error("Analytics tracking error:", c)), Promise.resolve();
|
|
289
|
+
return fetch(Lt, c).catch((g) => console.error("Analytics tracking error:", g)), Promise.resolve();
|
|
294
290
|
},
|
|
295
|
-
linkTrack(
|
|
296
|
-
|
|
297
|
-
const
|
|
298
|
-
if (
|
|
299
|
-
(
|
|
291
|
+
linkTrack(r, o, a, s) {
|
|
292
|
+
i[r] || (i[r] = { events: {}, resolvedDependencies: [] }), s.includes(a) || s.push(a);
|
|
293
|
+
const d = i[r];
|
|
294
|
+
if (d.events[a] = { props: o }, d.resolvedDependencies.push(a), s.every(
|
|
295
|
+
(c) => d.resolvedDependencies.includes(c)
|
|
300
296
|
)) {
|
|
301
|
-
const
|
|
302
|
-
this.track(
|
|
303
|
-
(
|
|
304
|
-
),
|
|
305
|
-
delete
|
|
297
|
+
const c = s.reduce((g, w) => d.events[w] ? { ...g, ...d.events[w].props } : g, {});
|
|
298
|
+
this.track(r, c), d.resolvedDependencies = d.resolvedDependencies.filter(
|
|
299
|
+
(g) => !s.includes(g)
|
|
300
|
+
), s.forEach((g) => {
|
|
301
|
+
delete d.events[g];
|
|
306
302
|
});
|
|
307
303
|
}
|
|
308
304
|
}
|
|
@@ -316,22 +312,22 @@ function Le() {
|
|
|
316
312
|
get: (t = !1) => t ? Date.now() - e : e
|
|
317
313
|
};
|
|
318
314
|
}
|
|
319
|
-
const
|
|
320
|
-
function
|
|
321
|
-
return e === x.Playground ? { headers: { [
|
|
315
|
+
const te = Le(), Me = Le(), Ne = Le();
|
|
316
|
+
function Ye(e) {
|
|
317
|
+
return e === x.Playground ? { headers: { [yt]: "true" } } : {};
|
|
322
318
|
}
|
|
323
|
-
async function
|
|
319
|
+
async function Ge(e, t, i, r, o = !1, a) {
|
|
324
320
|
try {
|
|
325
|
-
return !a && !
|
|
321
|
+
return !a && !Qe(r) && (a = await t.newChat(e.id, { persist: o }, Ye(r)), i.track("agent-chat", {
|
|
326
322
|
event: "created",
|
|
327
323
|
chatId: a.id,
|
|
328
324
|
mode: r
|
|
329
325
|
})), { chat: a, chatMode: (a == null ? void 0 : a.chat_mode) ?? r };
|
|
330
326
|
} catch (s) {
|
|
331
|
-
throw
|
|
327
|
+
throw bt(s) === "InsufficientCreditsError" ? new Error("InsufficientCreditsError") : new Error("Cannot create new chat");
|
|
332
328
|
}
|
|
333
329
|
}
|
|
334
|
-
const
|
|
330
|
+
const bt = (e) => {
|
|
335
331
|
try {
|
|
336
332
|
const t = JSON.parse(e.message);
|
|
337
333
|
return t == null ? void 0 : t.kind;
|
|
@@ -339,19 +335,19 @@ const Lt = (e) => {
|
|
|
339
335
|
return "UnknownError";
|
|
340
336
|
}
|
|
341
337
|
};
|
|
342
|
-
function
|
|
338
|
+
function jt(e) {
|
|
343
339
|
return e && e.length > 0 ? e : [];
|
|
344
340
|
}
|
|
345
|
-
function
|
|
346
|
-
const o =
|
|
341
|
+
function $t(e, t, i, r) {
|
|
342
|
+
const o = Ae(e, `${t}/v2/agents/${i}`, r);
|
|
347
343
|
return {
|
|
348
344
|
async createStream(a) {
|
|
349
345
|
return o.post("/sessions", a);
|
|
350
346
|
}
|
|
351
347
|
};
|
|
352
348
|
}
|
|
353
|
-
const
|
|
354
|
-
function
|
|
349
|
+
const Ze = (e, t) => (i, r) => e && console.log(`[${t}] ${i}`, r ?? "");
|
|
350
|
+
function Bt(e, t, i) {
|
|
355
351
|
const r = (t.timestamp - e.timestamp) / 1e3;
|
|
356
352
|
return {
|
|
357
353
|
duration: r,
|
|
@@ -371,7 +367,7 @@ function $t(e, t, i) {
|
|
|
371
367
|
lowFpsCount: i
|
|
372
368
|
};
|
|
373
369
|
}
|
|
374
|
-
function
|
|
370
|
+
function xt(e) {
|
|
375
371
|
return e.filter(
|
|
376
372
|
(t) => t.freezeCount > 0 || t.framesPerSecond < 21 || t.framesDropped > 0 || t.packetsLost > 0
|
|
377
373
|
).map((t) => {
|
|
@@ -382,7 +378,7 @@ function Bt(e) {
|
|
|
382
378
|
};
|
|
383
379
|
});
|
|
384
380
|
}
|
|
385
|
-
function
|
|
381
|
+
function Ft(e) {
|
|
386
382
|
let t = "", i = 0;
|
|
387
383
|
for (const r of e.values()) {
|
|
388
384
|
if (r && r.type === "codec" && r.mimeType.startsWith("video") && (t = r.mimeType.split("/")[1]), r && r.type === "candidate-pair") {
|
|
@@ -412,7 +408,7 @@ function xt(e) {
|
|
|
412
408
|
}
|
|
413
409
|
return {};
|
|
414
410
|
}
|
|
415
|
-
function
|
|
411
|
+
function Ve(e, t, i) {
|
|
416
412
|
const r = e.map((n, c) => c === 0 ? i ? {
|
|
417
413
|
timestamp: n.timestamp,
|
|
418
414
|
duration: 0,
|
|
@@ -464,32 +460,32 @@ function Ke(e, t, i) {
|
|
|
464
460
|
framesPerSecond: n.framesPerSecond,
|
|
465
461
|
freezeCount: n.freezeCount - e[c - 1].freezeCount,
|
|
466
462
|
freezeDuration: n.freezeDuration - e[c - 1].freezeDuration
|
|
467
|
-
}), o =
|
|
463
|
+
}), o = xt(r), a = o.reduce((n, c) => n + (c.causes.includes("low fps") ? 1 : 0), 0), s = r.filter((n) => !!n.avgJitterDelayInInterval).map((n) => n.avgJitterDelayInInterval), d = r.filter((n) => !!n.rtt).map((n) => n.rtt);
|
|
468
464
|
return {
|
|
469
465
|
webRTCStats: {
|
|
470
466
|
anomalies: o,
|
|
471
467
|
minRtt: Math.min(...d),
|
|
472
|
-
avgRtt:
|
|
468
|
+
avgRtt: ze(d),
|
|
473
469
|
maxRtt: Math.max(...d),
|
|
474
|
-
aggregateReport:
|
|
470
|
+
aggregateReport: Bt(e[0], e[e.length - 1], a),
|
|
475
471
|
minJitterDelayInInterval: Math.min(...s),
|
|
476
472
|
maxJitterDelayInInterval: Math.max(...s),
|
|
477
|
-
avgJitterDelayInInterval:
|
|
473
|
+
avgJitterDelayInInterval: ze(s)
|
|
478
474
|
},
|
|
479
475
|
codec: e[0].codec,
|
|
480
476
|
resolution: `${e[0].frameWidth}x${e[0].frameHeight}`
|
|
481
477
|
};
|
|
482
478
|
}
|
|
483
|
-
const Ce = 100,
|
|
484
|
-
function
|
|
479
|
+
const Ce = 100, zt = Math.max(Math.ceil(400 / Ce), 1), Kt = 0.25, Nt = 0.28;
|
|
480
|
+
function Vt() {
|
|
485
481
|
let e = 0, t, i, r = 0;
|
|
486
482
|
return (o) => {
|
|
487
483
|
for (const a of o.values())
|
|
488
484
|
if (a && a.type === "inbound-rtp" && a.kind === "video") {
|
|
489
485
|
const s = a.jitterBufferDelay, d = a.jitterBufferEmittedCount;
|
|
490
486
|
if (i && d > i) {
|
|
491
|
-
const
|
|
492
|
-
r =
|
|
487
|
+
const g = s - t, w = d - i;
|
|
488
|
+
r = g / w;
|
|
493
489
|
}
|
|
494
490
|
t = s, i = d;
|
|
495
491
|
const n = a.framesDecoded, c = n - e > 0;
|
|
@@ -498,32 +494,32 @@ function Nt() {
|
|
|
498
494
|
return { isReceiving: !1, avgJitterDelayInInterval: r };
|
|
499
495
|
};
|
|
500
496
|
}
|
|
501
|
-
function
|
|
502
|
-
let a = null, s = [], d, n = 0, c = !1,
|
|
503
|
-
const P =
|
|
504
|
-
async function
|
|
505
|
-
const
|
|
506
|
-
if (!
|
|
497
|
+
function et(e, t, i, r, o) {
|
|
498
|
+
let a = null, s = [], d, n = 0, c = !1, g = ne.Unknown, w = ne.Unknown, h = 0, f = 0;
|
|
499
|
+
const P = Vt();
|
|
500
|
+
async function J() {
|
|
501
|
+
const D = await e();
|
|
502
|
+
if (!D)
|
|
507
503
|
return;
|
|
508
|
-
const { isReceiving:
|
|
509
|
-
if (
|
|
510
|
-
n = 0,
|
|
511
|
-
else if (c && (n++, n >=
|
|
512
|
-
const
|
|
513
|
-
r == null || r(
|
|
504
|
+
const { isReceiving: k, avgJitterDelayInInterval: _, freezeCount: I } = P(D), F = Ft(D);
|
|
505
|
+
if (k)
|
|
506
|
+
n = 0, h = I - f, w = _ < Kt ? ne.Strong : _ > Nt && h > 1 ? ne.Weak : g, w !== g && (o == null || o(w), g = w, f += h, h = 0), c || (r == null || r(C.Start), d = s[s.length - 1], s = [], c = !0), s.push(F);
|
|
507
|
+
else if (c && (n++, n >= zt)) {
|
|
508
|
+
const $ = Ve(s, Ce, d);
|
|
509
|
+
r == null || r(C.Stop, $), t() || i(), f = I, c = !1;
|
|
514
510
|
}
|
|
515
511
|
}
|
|
516
512
|
return {
|
|
517
513
|
start: () => {
|
|
518
|
-
a || (a = setInterval(
|
|
514
|
+
a || (a = setInterval(J, Ce));
|
|
519
515
|
},
|
|
520
516
|
stop: () => {
|
|
521
517
|
a && (clearInterval(a), a = null);
|
|
522
518
|
},
|
|
523
|
-
getReport: () =>
|
|
519
|
+
getReport: () => Ve(s, Ce, d)
|
|
524
520
|
};
|
|
525
521
|
}
|
|
526
|
-
async function
|
|
522
|
+
async function Jt() {
|
|
527
523
|
try {
|
|
528
524
|
return await import("./livekit-client.esm-C1GRQdZY.js");
|
|
529
525
|
} catch {
|
|
@@ -532,321 +528,325 @@ async function Vt() {
|
|
|
532
528
|
);
|
|
533
529
|
}
|
|
534
530
|
}
|
|
535
|
-
const
|
|
531
|
+
const Ut = {
|
|
536
532
|
excellent: ne.Strong,
|
|
537
533
|
good: ne.Strong,
|
|
538
534
|
poor: ne.Weak,
|
|
539
535
|
lost: ne.Unknown,
|
|
540
536
|
unknown: ne.Unknown
|
|
541
|
-
},
|
|
537
|
+
}, he = JSON.stringify({
|
|
542
538
|
kind: "InternalServerError",
|
|
543
539
|
description: "Stream Error"
|
|
544
540
|
});
|
|
545
|
-
var
|
|
546
|
-
function
|
|
541
|
+
var Pe = /* @__PURE__ */ ((e) => (e.Chat = "lk.chat", e.Speak = "did.speak", e.Interrupt = "did.interrupt", e))(Pe || {});
|
|
542
|
+
function Ie(e, t, i) {
|
|
547
543
|
var r, o;
|
|
548
544
|
throw t("Failed to connect to LiveKit room:", e), (r = i.onConnectionStateChange) == null || r.call(i, T.Fail, "internal:init-error"), (o = i.onError) == null || o.call(i, e, { sessionId: "" }), e;
|
|
549
545
|
}
|
|
550
|
-
async function
|
|
551
|
-
var
|
|
552
|
-
const r =
|
|
553
|
-
let
|
|
554
|
-
const
|
|
555
|
-
let
|
|
556
|
-
|
|
546
|
+
async function Wt(e, t, i) {
|
|
547
|
+
var be;
|
|
548
|
+
const r = Ze(i.debug || !1, "LiveKitStreamingManager"), { Room: o, RoomEvent: a, ConnectionState: s, Track: d } = await Jt(), { callbacks: n, auth: c, baseURL: g, analytics: w, microphoneStream: h } = i;
|
|
549
|
+
let f = null, P = !1;
|
|
550
|
+
const J = re.Fluent;
|
|
551
|
+
let D = null, k = null, _ = null, I = null, F = !1;
|
|
552
|
+
f = new o({
|
|
557
553
|
adaptiveStream: !1,
|
|
558
554
|
// Must be false to use mediaStreamTrack directly
|
|
559
555
|
dynacast: !0
|
|
560
556
|
});
|
|
561
|
-
let
|
|
562
|
-
const
|
|
563
|
-
let
|
|
564
|
-
const
|
|
565
|
-
let
|
|
557
|
+
let $ = null;
|
|
558
|
+
const H = 2e4;
|
|
559
|
+
let Z = O.Idle;
|
|
560
|
+
const se = $t(c, g || pe, e, n.onError);
|
|
561
|
+
let N, u, S;
|
|
566
562
|
try {
|
|
567
|
-
const l = await
|
|
563
|
+
const l = await se.createStream({
|
|
568
564
|
transport_provider: ke.Livekit,
|
|
569
565
|
chat_persist: t.chat_persist ?? !0
|
|
570
|
-
}), { id:
|
|
571
|
-
(
|
|
566
|
+
}), { id: p, session_token: v, session_url: M } = l;
|
|
567
|
+
(be = n.onStreamCreated) == null || be.call(n, { session_id: p, stream_id: p, agent_id: e }), N = p, u = v, S = M, await f.prepareConnection(S, u);
|
|
572
568
|
} catch (l) {
|
|
573
|
-
|
|
569
|
+
Ie(l, r, n);
|
|
574
570
|
}
|
|
575
|
-
if (!
|
|
571
|
+
if (!S || !u || !N)
|
|
576
572
|
return Promise.reject(new Error("Failed to initialize LiveKit stream"));
|
|
577
|
-
|
|
578
|
-
function R(l,
|
|
573
|
+
f.on(a.ConnectionStateChanged, z).on(a.ConnectionQualityChanged, b).on(a.ParticipantConnected, A).on(a.ParticipantDisconnected, K).on(a.TrackSubscribed, j).on(a.TrackUnsubscribed, B).on(a.DataReceived, Y).on(a.MediaDevicesError, ie).on(a.TranscriptionReceived, R).on(a.EncryptionError, y).on(a.TrackSubscriptionFailed, m);
|
|
574
|
+
function R(l, p) {
|
|
579
575
|
var v;
|
|
580
|
-
|
|
576
|
+
p != null && p.isLocal && (te.update(), Z === O.Talking && ((v = n.onInterruptDetected) == null || v.call(n, { type: "audio" }), Z = O.Idle));
|
|
581
577
|
}
|
|
582
578
|
try {
|
|
583
|
-
await
|
|
579
|
+
await f.connect(S, u), r("LiveKit room joined successfully"), $ = setTimeout(() => {
|
|
584
580
|
var l;
|
|
585
|
-
r("Track subscription timeout - no track subscribed within 30 seconds after connect"),
|
|
581
|
+
r("Track subscription timeout - no track subscribed within 30 seconds after connect"), $ = null, w.track("connectivity-error", {
|
|
586
582
|
error: "Track subscription timeout",
|
|
587
|
-
sessionId:
|
|
588
|
-
}), (l = n.onError) == null || l.call(n, new Error("Track subscription timeout"), { sessionId:
|
|
589
|
-
},
|
|
583
|
+
sessionId: N
|
|
584
|
+
}), (l = n.onError) == null || l.call(n, new Error("Track subscription timeout"), { sessionId: N }), Re("internal:track-subscription-timeout");
|
|
585
|
+
}, H);
|
|
590
586
|
} catch (l) {
|
|
591
|
-
|
|
587
|
+
Ie(l, r, n);
|
|
592
588
|
}
|
|
593
|
-
|
|
594
|
-
"stream-type":
|
|
589
|
+
w.enrich({
|
|
590
|
+
"stream-type": J
|
|
595
591
|
});
|
|
596
|
-
function
|
|
597
|
-
var
|
|
592
|
+
function z(l) {
|
|
593
|
+
var p, v, M, U;
|
|
598
594
|
switch (r("Connection state changed:", l), l) {
|
|
599
595
|
case s.Connecting:
|
|
600
|
-
r("CALLBACK: onConnectionStateChange(Connecting)"), (
|
|
596
|
+
r("CALLBACK: onConnectionStateChange(Connecting)"), (p = n.onConnectionStateChange) == null || p.call(n, T.Connecting, "livekit:connecting");
|
|
601
597
|
break;
|
|
602
598
|
case s.Connected:
|
|
603
599
|
r("LiveKit room connected successfully"), P = !0;
|
|
604
600
|
break;
|
|
605
601
|
case s.Disconnected:
|
|
606
|
-
r("LiveKit room disconnected"), P = !1,
|
|
602
|
+
r("LiveKit room disconnected"), P = !1, F = !1, (v = n.onConnectionStateChange) == null || v.call(n, T.Disconnected, "livekit:disconnected");
|
|
607
603
|
break;
|
|
608
604
|
case s.Reconnecting:
|
|
609
|
-
r("LiveKit room reconnecting..."), (
|
|
605
|
+
r("LiveKit room reconnecting..."), (M = n.onConnectionStateChange) == null || M.call(n, T.Connecting, "livekit:reconnecting");
|
|
610
606
|
break;
|
|
611
607
|
case s.SignalReconnecting:
|
|
612
|
-
r("LiveKit room signal reconnecting..."), (
|
|
608
|
+
r("LiveKit room signal reconnecting..."), (U = n.onConnectionStateChange) == null || U.call(n, T.Connecting, "livekit:signal-reconnecting");
|
|
613
609
|
break;
|
|
614
610
|
}
|
|
615
611
|
}
|
|
616
|
-
function
|
|
612
|
+
function b(l, p) {
|
|
617
613
|
var v;
|
|
618
|
-
r("Connection quality:", l),
|
|
614
|
+
r("Connection quality:", l), p != null && p.isLocal && ((v = n.onConnectivityStateChange) == null || v.call(n, Ut[l]));
|
|
619
615
|
}
|
|
620
|
-
function
|
|
616
|
+
function A(l) {
|
|
621
617
|
r("Participant connected:", l.identity);
|
|
622
618
|
}
|
|
623
|
-
function
|
|
624
|
-
r("Participant disconnected:", l.identity),
|
|
619
|
+
function K(l) {
|
|
620
|
+
r("Participant disconnected:", l.identity), Re("livekit:participant-disconnected");
|
|
625
621
|
}
|
|
626
|
-
function
|
|
627
|
-
var
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
622
|
+
function q() {
|
|
623
|
+
var l;
|
|
624
|
+
I !== C.Start && (r("CALLBACK: onVideoStateChange(Start)"), I = C.Start, (l = n.onVideoStateChange) == null || l.call(n, C.Start));
|
|
625
|
+
}
|
|
626
|
+
function W(l) {
|
|
627
|
+
var p;
|
|
628
|
+
I !== C.Stop && (r("CALLBACK: onVideoStateChange(Stop)"), I = C.Stop, (p = n.onVideoStateChange) == null || p.call(n, C.Stop, l));
|
|
629
|
+
}
|
|
630
|
+
function j(l, p, v) {
|
|
631
|
+
var U, V, ae;
|
|
632
|
+
r(`Track subscribed: ${l.kind} from ${v.identity}`), $ && (clearTimeout($), $ = null, r("Track subscription timeout cleared"));
|
|
633
|
+
const M = l.mediaStreamTrack;
|
|
634
|
+
if (!M) {
|
|
631
635
|
r(`No mediaStreamTrack available for ${l.kind}`);
|
|
632
636
|
return;
|
|
633
637
|
}
|
|
634
|
-
|
|
638
|
+
D ? (D.addTrack(M), r(`Added ${l.kind} track to shared MediaStream`)) : (D = new MediaStream([M]), r(`Created shared MediaStream with ${l.kind} track`)), l.kind === "video" && ((U = n.onStreamReady) == null || U.call(n), r("CALLBACK: onSrcObjectReady"), (V = n.onSrcObjectReady) == null || V.call(n, D), F || (F = !0, r("CALLBACK: onConnectionStateChange(Connected)"), (ae = n.onConnectionStateChange) == null || ae.call(n, T.Connected, "livekit:track-subscribed")), _ = et(
|
|
635
639
|
() => l.getRTCStatsReport(),
|
|
636
640
|
() => P,
|
|
637
|
-
|
|
638
|
-
(
|
|
639
|
-
r(`Video state change: ${
|
|
641
|
+
St,
|
|
642
|
+
(le, ye) => {
|
|
643
|
+
r(`Video state change: ${le}`), le === C.Start ? q() : le === C.Stop && W(ye);
|
|
640
644
|
}
|
|
641
|
-
),
|
|
645
|
+
), _.start());
|
|
642
646
|
}
|
|
643
|
-
function
|
|
644
|
-
|
|
645
|
-
if (r(`Track unsubscribed: ${l.kind} from ${v.identity}`), l.kind === "video") {
|
|
646
|
-
const N = L == null ? void 0 : L.getReport();
|
|
647
|
-
L == null || L.stop(), L = null, (k = n.onVideoStateChange) == null || k.call(n, M.Stop, N);
|
|
648
|
-
}
|
|
647
|
+
function B(l, p, v) {
|
|
648
|
+
r(`Track unsubscribed: ${l.kind} from ${v.identity}`), l.kind === "video" && (W(_ == null ? void 0 : _.getReport()), _ == null || _.stop(), _ = null);
|
|
649
649
|
}
|
|
650
|
-
function
|
|
651
|
-
var
|
|
652
|
-
const
|
|
650
|
+
function Y(l, p, v, M) {
|
|
651
|
+
var V, ae, le, ye, je, $e, Be, xe;
|
|
652
|
+
const U = new TextDecoder().decode(l);
|
|
653
653
|
try {
|
|
654
|
-
const
|
|
655
|
-
if (r("Data received:", { subject:
|
|
656
|
-
const
|
|
657
|
-
(
|
|
658
|
-
event:
|
|
659
|
-
...
|
|
654
|
+
const Q = JSON.parse(U), oe = M || Q.subject;
|
|
655
|
+
if (r("Data received:", { subject: oe, data: Q }), oe === L.ChatAnswer) {
|
|
656
|
+
const ee = X.Answer;
|
|
657
|
+
(V = n.onMessage) == null || V.call(n, ee, {
|
|
658
|
+
event: ee,
|
|
659
|
+
...Q
|
|
660
660
|
});
|
|
661
|
-
} else if (
|
|
662
|
-
const
|
|
663
|
-
(
|
|
664
|
-
event:
|
|
665
|
-
...
|
|
661
|
+
} else if (oe === L.ChatPartial) {
|
|
662
|
+
const ee = X.Partial;
|
|
663
|
+
(ae = n.onMessage) == null || ae.call(n, ee, {
|
|
664
|
+
event: ee,
|
|
665
|
+
...Q
|
|
666
666
|
});
|
|
667
667
|
} else if ([
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
].includes(
|
|
673
|
-
|
|
674
|
-
const
|
|
675
|
-
i.debug && ((
|
|
676
|
-
id:
|
|
677
|
-
name:
|
|
678
|
-
}), (
|
|
679
|
-
} else if (
|
|
680
|
-
const
|
|
681
|
-
(
|
|
682
|
-
event:
|
|
683
|
-
...
|
|
668
|
+
L.StreamVideoCreated,
|
|
669
|
+
L.StreamVideoDone,
|
|
670
|
+
L.StreamVideoError,
|
|
671
|
+
L.StreamVideoRejected
|
|
672
|
+
].includes(oe)) {
|
|
673
|
+
Z = oe === L.StreamVideoCreated ? O.Talking : O.Idle, (le = n.onAgentActivityStateChange) == null || le.call(n, Z);
|
|
674
|
+
const ee = ((je = (ye = _ == null ? void 0 : _.getReport()) == null ? void 0 : ye.webRTCStats) == null ? void 0 : je.avgRtt) ?? 0, ve = ee > 0 ? Math.round(ee / 2 * 1e3) : 0, Fe = { ...Q, downstreamNetworkLatency: ve };
|
|
675
|
+
i.debug && (($e = Q == null ? void 0 : Q.metadata) != null && $e.sentiment) && (Fe.sentiment = {
|
|
676
|
+
id: Q.metadata.sentiment.id,
|
|
677
|
+
name: Q.metadata.sentiment.sentiment
|
|
678
|
+
}), (Be = n.onMessage) == null || Be.call(n, oe, Fe);
|
|
679
|
+
} else if (oe === L.ChatAudioTranscribed) {
|
|
680
|
+
const ee = X.Transcribe;
|
|
681
|
+
(xe = n.onMessage) == null || xe.call(n, ee, {
|
|
682
|
+
event: ee,
|
|
683
|
+
...Q
|
|
684
684
|
}), queueMicrotask(() => {
|
|
685
685
|
var ve;
|
|
686
|
-
(ve = n.onAgentActivityStateChange) == null || ve.call(n,
|
|
686
|
+
(ve = n.onAgentActivityStateChange) == null || ve.call(n, O.Loading);
|
|
687
687
|
});
|
|
688
688
|
}
|
|
689
|
-
} catch (
|
|
690
|
-
r("Failed to parse data channel message:",
|
|
689
|
+
} catch (Q) {
|
|
690
|
+
r("Failed to parse data channel message:", Q);
|
|
691
691
|
}
|
|
692
692
|
}
|
|
693
|
-
function
|
|
694
|
-
var
|
|
695
|
-
r("Media devices error:", l), (
|
|
693
|
+
function ie(l) {
|
|
694
|
+
var p;
|
|
695
|
+
r("Media devices error:", l), (p = n.onError) == null || p.call(n, new Error(he), { sessionId: N });
|
|
696
696
|
}
|
|
697
|
-
function
|
|
698
|
-
var
|
|
699
|
-
r("Encryption error:", l), (
|
|
697
|
+
function y(l) {
|
|
698
|
+
var p;
|
|
699
|
+
r("Encryption error:", l), (p = n.onError) == null || p.call(n, new Error(he), { sessionId: N });
|
|
700
700
|
}
|
|
701
|
-
function
|
|
702
|
-
r("Track subscription failed:", { trackSid: l, participant:
|
|
701
|
+
function m(l, p, v) {
|
|
702
|
+
r("Track subscription failed:", { trackSid: l, participant: p, reason: v });
|
|
703
703
|
}
|
|
704
|
-
function
|
|
705
|
-
if (!
|
|
706
|
-
const
|
|
707
|
-
if (
|
|
708
|
-
for (const [v,
|
|
709
|
-
if (
|
|
710
|
-
const
|
|
711
|
-
if (
|
|
712
|
-
return
|
|
704
|
+
function E(l) {
|
|
705
|
+
if (!f) return null;
|
|
706
|
+
const p = f.localParticipant.audioTrackPublications;
|
|
707
|
+
if (p) {
|
|
708
|
+
for (const [v, M] of p)
|
|
709
|
+
if (M.source === d.Source.Microphone && M.track) {
|
|
710
|
+
const V = M.track.mediaStreamTrack;
|
|
711
|
+
if (V === l || V && V.id === l.id)
|
|
712
|
+
return M;
|
|
713
713
|
}
|
|
714
714
|
}
|
|
715
715
|
return null;
|
|
716
716
|
}
|
|
717
|
-
function
|
|
718
|
-
if (!
|
|
717
|
+
function G(l) {
|
|
718
|
+
if (!k || !k.track)
|
|
719
719
|
return !1;
|
|
720
|
-
const
|
|
721
|
-
return
|
|
720
|
+
const p = k.track.mediaStreamTrack;
|
|
721
|
+
return p !== l && (p == null ? void 0 : p.id) !== l.id;
|
|
722
722
|
}
|
|
723
|
-
async function
|
|
724
|
-
var
|
|
725
|
-
if (!P || !
|
|
723
|
+
async function ce(l) {
|
|
724
|
+
var U, V;
|
|
725
|
+
if (!P || !f)
|
|
726
726
|
throw r("Room is not connected, cannot publish microphone stream"), new Error("Room is not connected");
|
|
727
|
-
const
|
|
728
|
-
if (
|
|
727
|
+
const p = l.getAudioTracks();
|
|
728
|
+
if (p.length === 0) {
|
|
729
729
|
r("No audio track found in the provided MediaStream");
|
|
730
730
|
return;
|
|
731
731
|
}
|
|
732
|
-
const v =
|
|
733
|
-
if (
|
|
732
|
+
const v = p[0], M = E(v);
|
|
733
|
+
if (M) {
|
|
734
734
|
r("Microphone track is already published, skipping", {
|
|
735
735
|
trackId: v.id,
|
|
736
|
-
publishedTrackId: (
|
|
737
|
-
}),
|
|
736
|
+
publishedTrackId: (V = (U = M.track) == null ? void 0 : U.mediaStreamTrack) == null ? void 0 : V.id
|
|
737
|
+
}), k = M;
|
|
738
738
|
return;
|
|
739
739
|
}
|
|
740
|
-
|
|
740
|
+
G(v) && (r("Unpublishing existing microphone track before publishing new one"), await de()), r("Publishing microphone track from provided MediaStream", { trackId: v.id });
|
|
741
741
|
try {
|
|
742
|
-
|
|
742
|
+
k = await f.localParticipant.publishTrack(v, {
|
|
743
743
|
source: d.Source.Microphone
|
|
744
|
-
}), r("Microphone track published successfully", { trackSid:
|
|
745
|
-
} catch (
|
|
746
|
-
throw r("Failed to publish microphone track:",
|
|
744
|
+
}), r("Microphone track published successfully", { trackSid: k.trackSid });
|
|
745
|
+
} catch (ae) {
|
|
746
|
+
throw r("Failed to publish microphone track:", ae), ae;
|
|
747
747
|
}
|
|
748
748
|
}
|
|
749
|
-
async function
|
|
750
|
-
if (!(!
|
|
749
|
+
async function de() {
|
|
750
|
+
if (!(!k || !k.track))
|
|
751
751
|
try {
|
|
752
|
-
|
|
752
|
+
f && (await f.localParticipant.unpublishTrack(k.track), r("Microphone track unpublished"));
|
|
753
753
|
} catch (l) {
|
|
754
754
|
r("Error unpublishing microphone track:", l);
|
|
755
755
|
} finally {
|
|
756
|
-
|
|
756
|
+
k = null;
|
|
757
757
|
}
|
|
758
758
|
}
|
|
759
|
-
function
|
|
760
|
-
|
|
759
|
+
function we() {
|
|
760
|
+
D && (D.getTracks().forEach((l) => l.stop()), D = null);
|
|
761
761
|
}
|
|
762
|
-
async function
|
|
763
|
-
var v,
|
|
764
|
-
if (!P || !
|
|
765
|
-
r("Room is not connected for sending messages"), (v = n.onError) == null || v.call(n, new Error(
|
|
766
|
-
sessionId:
|
|
762
|
+
async function ue(l, p) {
|
|
763
|
+
var v, M;
|
|
764
|
+
if (!P || !f) {
|
|
765
|
+
r("Room is not connected for sending messages"), (v = n.onError) == null || v.call(n, new Error(he), {
|
|
766
|
+
sessionId: N
|
|
767
767
|
});
|
|
768
768
|
return;
|
|
769
769
|
}
|
|
770
770
|
try {
|
|
771
|
-
await
|
|
772
|
-
} catch (
|
|
773
|
-
r("Failed to send message:",
|
|
771
|
+
await f.localParticipant.sendText(l, { topic: p }), r("Message sent successfully:", l);
|
|
772
|
+
} catch (U) {
|
|
773
|
+
r("Failed to send message:", U), (M = n.onError) == null || M.call(n, new Error(he), { sessionId: N });
|
|
774
774
|
}
|
|
775
775
|
}
|
|
776
|
-
async function
|
|
777
|
-
var
|
|
776
|
+
async function tt(l) {
|
|
777
|
+
var p;
|
|
778
778
|
try {
|
|
779
|
-
const
|
|
780
|
-
return
|
|
779
|
+
const M = JSON.parse(l).topic;
|
|
780
|
+
return ue("", M);
|
|
781
781
|
} catch (v) {
|
|
782
|
-
r("Failed to send data channel message:", v), (
|
|
782
|
+
r("Failed to send data channel message:", v), (p = n.onError) == null || p.call(n, new Error(he), { sessionId: N });
|
|
783
783
|
}
|
|
784
784
|
}
|
|
785
|
-
function
|
|
786
|
-
return
|
|
785
|
+
function nt(l) {
|
|
786
|
+
return ue(
|
|
787
787
|
l,
|
|
788
788
|
"lk.chat"
|
|
789
789
|
/* Chat */
|
|
790
790
|
);
|
|
791
791
|
}
|
|
792
|
-
async function
|
|
793
|
-
var
|
|
794
|
-
|
|
792
|
+
async function Re(l) {
|
|
793
|
+
var p, v;
|
|
794
|
+
$ && (clearTimeout($), $ = null), f && (await de(), (p = n.onConnectionStateChange) == null || p.call(n, T.Disconnecting, l), await f.disconnect()), we(), P = !1, F = !1, (v = n.onAgentActivityStateChange) == null || v.call(n, O.Idle), Z = O.Idle;
|
|
795
795
|
}
|
|
796
796
|
return {
|
|
797
797
|
speak(l) {
|
|
798
|
-
const
|
|
799
|
-
return
|
|
800
|
-
|
|
798
|
+
const p = typeof l == "string" ? l : JSON.stringify(l);
|
|
799
|
+
return ue(
|
|
800
|
+
p,
|
|
801
801
|
"did.speak"
|
|
802
802
|
/* Speak */
|
|
803
803
|
);
|
|
804
804
|
},
|
|
805
|
-
disconnect: () =>
|
|
805
|
+
disconnect: () => Re("user:disconnect"),
|
|
806
806
|
async reconnect() {
|
|
807
|
-
var l,
|
|
808
|
-
if ((
|
|
807
|
+
var l, p;
|
|
808
|
+
if ((f == null ? void 0 : f.state) === s.Connected) {
|
|
809
809
|
r("Room is already connected");
|
|
810
810
|
return;
|
|
811
811
|
}
|
|
812
|
-
if (!
|
|
812
|
+
if (!f || !S || !u)
|
|
813
813
|
throw r("Cannot reconnect: missing room, URL or token"), new Error("Cannot reconnect: session not available");
|
|
814
|
-
r("Reconnecting to LiveKit room, state:",
|
|
814
|
+
r("Reconnecting to LiveKit room, state:", f.state), F = !1, (l = n.onConnectionStateChange) == null || l.call(n, T.Connecting, "user:reconnect");
|
|
815
815
|
try {
|
|
816
|
-
if (await
|
|
817
|
-
if (r("Waiting for agent to join..."), !await new Promise((
|
|
818
|
-
const
|
|
819
|
-
|
|
820
|
-
}, 5e3),
|
|
821
|
-
clearTimeout(
|
|
816
|
+
if (await f.connect(S, u), r("Room reconnected"), P = !0, f.remoteParticipants.size === 0) {
|
|
817
|
+
if (r("Waiting for agent to join..."), !await new Promise((M) => {
|
|
818
|
+
const U = setTimeout(() => {
|
|
819
|
+
f == null || f.off(a.ParticipantConnected, V), M(!1);
|
|
820
|
+
}, 5e3), V = () => {
|
|
821
|
+
clearTimeout(U), f == null || f.off(a.ParticipantConnected, V), M(!0);
|
|
822
822
|
};
|
|
823
|
-
|
|
823
|
+
f == null || f.on(a.ParticipantConnected, V);
|
|
824
824
|
}))
|
|
825
|
-
throw r("Agent did not join within timeout"), await
|
|
825
|
+
throw r("Agent did not join within timeout"), await f.disconnect(), new Error("Agent did not rejoin the room");
|
|
826
826
|
r("Agent joined, reconnection successful");
|
|
827
827
|
}
|
|
828
828
|
} catch (v) {
|
|
829
|
-
throw r("Failed to reconnect:", v), (
|
|
829
|
+
throw r("Failed to reconnect:", v), (p = n.onConnectionStateChange) == null || p.call(n, T.Fail, "user:reconnect-failed"), v;
|
|
830
830
|
}
|
|
831
831
|
},
|
|
832
|
-
sendDataChannelMessage:
|
|
833
|
-
sendTextMessage:
|
|
834
|
-
publishMicrophoneStream:
|
|
835
|
-
unpublishMicrophoneStream:
|
|
836
|
-
sessionId:
|
|
837
|
-
streamId:
|
|
838
|
-
streamType:
|
|
832
|
+
sendDataChannelMessage: tt,
|
|
833
|
+
sendTextMessage: nt,
|
|
834
|
+
publishMicrophoneStream: ce,
|
|
835
|
+
unpublishMicrophoneStream: de,
|
|
836
|
+
sessionId: N,
|
|
837
|
+
streamId: N,
|
|
838
|
+
streamType: J,
|
|
839
839
|
interruptAvailable: !0,
|
|
840
840
|
triggersAvailable: !1
|
|
841
841
|
};
|
|
842
842
|
}
|
|
843
|
-
const
|
|
843
|
+
const Ot = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
844
844
|
__proto__: null,
|
|
845
|
-
DataChannelTopic:
|
|
846
|
-
createLiveKitStreamingManager:
|
|
847
|
-
handleInitError:
|
|
845
|
+
DataChannelTopic: Pe,
|
|
846
|
+
createLiveKitStreamingManager: Wt,
|
|
847
|
+
handleInitError: Ie
|
|
848
848
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
849
|
-
function
|
|
849
|
+
function Ht(e, t, i) {
|
|
850
850
|
if (!e)
|
|
851
851
|
throw new Error("Please connect to the agent first");
|
|
852
852
|
if (!e.interruptAvailable)
|
|
@@ -856,52 +856,52 @@ function Ot(e, t, i) {
|
|
|
856
856
|
if (!i)
|
|
857
857
|
throw new Error("No active video to interrupt");
|
|
858
858
|
}
|
|
859
|
-
async function
|
|
859
|
+
async function qt(e, t) {
|
|
860
860
|
const i = {
|
|
861
|
-
type:
|
|
861
|
+
type: L.StreamInterrupt,
|
|
862
862
|
videoId: t,
|
|
863
863
|
timestamp: Date.now()
|
|
864
864
|
};
|
|
865
865
|
e.sendDataChannelMessage(JSON.stringify(i));
|
|
866
866
|
}
|
|
867
|
-
async function
|
|
867
|
+
async function Qt(e) {
|
|
868
868
|
const t = {
|
|
869
|
-
topic:
|
|
869
|
+
topic: Pe.Interrupt
|
|
870
870
|
};
|
|
871
871
|
e.sendDataChannelMessage(JSON.stringify(t));
|
|
872
872
|
}
|
|
873
|
-
function
|
|
873
|
+
function Xt(e) {
|
|
874
874
|
return new Promise((t, i) => {
|
|
875
|
-
const { callbacks: r, host: o, auth: a, externalId: s } = e, { onMessage: d = null, onOpen: n = null, onClose: c = null, onError:
|
|
876
|
-
|
|
877
|
-
console.error(
|
|
878
|
-
},
|
|
879
|
-
n == null || n(
|
|
875
|
+
const { callbacks: r, host: o, auth: a, externalId: s } = e, { onMessage: d = null, onOpen: n = null, onClose: c = null, onError: g = null } = r || {}, w = new WebSocket(`${o}?authorization=${encodeURIComponent(Xe(a, s))}`);
|
|
876
|
+
w.onmessage = d, w.onclose = c, w.onerror = (h) => {
|
|
877
|
+
console.error(h), g == null || g("Websocket failed to connect", h), i(h);
|
|
878
|
+
}, w.onopen = (h) => {
|
|
879
|
+
n == null || n(h), t(w);
|
|
880
880
|
};
|
|
881
881
|
});
|
|
882
882
|
}
|
|
883
|
-
async function
|
|
883
|
+
async function Yt(e) {
|
|
884
884
|
const { retries: t = 1 } = e;
|
|
885
885
|
let i = null;
|
|
886
886
|
for (let r = 0; (i == null ? void 0 : i.readyState) !== WebSocket.OPEN; r++)
|
|
887
887
|
try {
|
|
888
|
-
i = await
|
|
888
|
+
i = await Xt(e);
|
|
889
889
|
} catch (o) {
|
|
890
890
|
if (r === t)
|
|
891
891
|
throw o;
|
|
892
|
-
await
|
|
892
|
+
await He(r * 500);
|
|
893
893
|
}
|
|
894
894
|
return i;
|
|
895
895
|
}
|
|
896
|
-
async function
|
|
897
|
-
const o = i != null && i.onMessage ? [i.onMessage] : [], a = await
|
|
896
|
+
async function Gt(e, t, i, r) {
|
|
897
|
+
const o = i != null && i.onMessage ? [i.onMessage] : [], a = await Yt({
|
|
898
898
|
auth: e,
|
|
899
899
|
host: t,
|
|
900
900
|
externalId: r,
|
|
901
901
|
callbacks: {
|
|
902
902
|
onError: (s) => {
|
|
903
903
|
var d;
|
|
904
|
-
return (d = i.onError) == null ? void 0 : d.call(i, new
|
|
904
|
+
return (d = i.onError) == null ? void 0 : d.call(i, new st(s));
|
|
905
905
|
},
|
|
906
906
|
onMessage(s) {
|
|
907
907
|
const d = JSON.parse(s.data);
|
|
@@ -915,7 +915,7 @@ async function Yt(e, t, i, r) {
|
|
|
915
915
|
subscribeToEvents: (s) => o.push(s)
|
|
916
916
|
};
|
|
917
917
|
}
|
|
918
|
-
function
|
|
918
|
+
function Zt(e) {
|
|
919
919
|
if (e.answer !== void 0)
|
|
920
920
|
return e.answer;
|
|
921
921
|
let t = 0, i = "";
|
|
@@ -923,7 +923,7 @@ function Gt(e) {
|
|
|
923
923
|
i += e[t++];
|
|
924
924
|
return i;
|
|
925
925
|
}
|
|
926
|
-
function
|
|
926
|
+
function en(e, t, i) {
|
|
927
927
|
if (!e.content)
|
|
928
928
|
return;
|
|
929
929
|
const r = t.messages[t.messages.length - 1];
|
|
@@ -937,17 +937,17 @@ function Zt(e, t, i) {
|
|
|
937
937
|
};
|
|
938
938
|
t.messages.push(o), i == null || i([...t.messages], "user");
|
|
939
939
|
}
|
|
940
|
-
function
|
|
941
|
-
if (e ===
|
|
942
|
-
|
|
940
|
+
function tn(e, t, i, r, o) {
|
|
941
|
+
if (e === X.Transcribe && t.content) {
|
|
942
|
+
en(t, r, o);
|
|
943
943
|
return;
|
|
944
944
|
}
|
|
945
|
-
if (!(e ===
|
|
945
|
+
if (!(e === X.Partial || e === X.Answer))
|
|
946
946
|
return;
|
|
947
947
|
const a = r.messages[r.messages.length - 1];
|
|
948
948
|
let s;
|
|
949
949
|
if (a != null && a.transcribed && a.role === "user")
|
|
950
|
-
e ===
|
|
950
|
+
e === X.Answer && t.content, s = {
|
|
951
951
|
id: t.id || `assistant-${Date.now()}`,
|
|
952
952
|
role: t.role || "assistant",
|
|
953
953
|
content: t.content || "",
|
|
@@ -958,48 +958,49 @@ function en(e, t, i, r, o) {
|
|
|
958
958
|
else
|
|
959
959
|
return;
|
|
960
960
|
const { content: d, sequence: n } = t;
|
|
961
|
-
e ===
|
|
962
|
-
const c =
|
|
963
|
-
(s.content !== c || e ===
|
|
961
|
+
e === X.Partial ? i[n] = d : i.answer = d;
|
|
962
|
+
const c = Zt(i);
|
|
963
|
+
(s.content !== c || e === X.Answer) && (s.content = c, o == null || o([...r.messages], e));
|
|
964
964
|
}
|
|
965
|
-
function
|
|
965
|
+
function nn(e, t, i, r, o) {
|
|
966
966
|
let a = {};
|
|
967
967
|
const s = () => a = {};
|
|
968
968
|
let d = "answer";
|
|
969
|
-
const n = (c,
|
|
970
|
-
var
|
|
971
|
-
|
|
969
|
+
const n = (c, g) => {
|
|
970
|
+
var w, h;
|
|
971
|
+
g === "user" && s(), d = g, (h = (w = i.callbacks).onNewMessage) == null || h.call(w, c, g);
|
|
972
972
|
};
|
|
973
973
|
return {
|
|
974
974
|
clearQueue: s,
|
|
975
|
-
onMessage: (c,
|
|
976
|
-
var
|
|
977
|
-
if ("content" in
|
|
978
|
-
const
|
|
979
|
-
|
|
975
|
+
onMessage: (c, g) => {
|
|
976
|
+
var w, h;
|
|
977
|
+
if ("content" in g) {
|
|
978
|
+
const f = c === L.ChatAnswer ? X.Answer : c === L.ChatAudioTranscribed ? X.Transcribe : c;
|
|
979
|
+
tn(f, g, a, t, n), f === X.Answer && e.track("agent-message-received", {
|
|
980
|
+
content: g.content,
|
|
980
981
|
messages: t.messages.length,
|
|
981
982
|
mode: t.chatMode
|
|
982
983
|
});
|
|
983
984
|
} else {
|
|
984
|
-
const
|
|
985
|
-
if (c = c, c ===
|
|
986
|
-
const
|
|
987
|
-
if ((
|
|
988
|
-
const
|
|
989
|
-
t.messages[t.messages.length - 1] =
|
|
985
|
+
const f = L, P = [f.StreamVideoDone, f.StreamVideoError, f.StreamVideoRejected], J = [f.StreamFailed, f.StreamVideoError, f.StreamVideoRejected], D = At(g, r, { mode: t.chatMode });
|
|
986
|
+
if (c = c, c === f.StreamVideoCreated && (e.linkTrack("agent-video", D, f.StreamVideoCreated, ["start"]), g.sentiment)) {
|
|
987
|
+
const k = t.messages[t.messages.length - 1];
|
|
988
|
+
if ((k == null ? void 0 : k.role) === "assistant") {
|
|
989
|
+
const _ = { ...k, sentiment: g.sentiment };
|
|
990
|
+
t.messages[t.messages.length - 1] = _, n == null || n([...t.messages], d);
|
|
990
991
|
}
|
|
991
992
|
}
|
|
992
993
|
if (P.includes(c)) {
|
|
993
|
-
const
|
|
994
|
-
|
|
994
|
+
const k = c.split("/")[1];
|
|
995
|
+
J.includes(c) ? e.track("agent-video", { ...D, event: k }) : e.linkTrack("agent-video", { ...D, event: k }, c, ["done"]);
|
|
995
996
|
}
|
|
996
|
-
|
|
997
|
+
J.includes(c) && ((h = (w = i.callbacks).onError) == null || h.call(w, new Error(`Stream failed with event ${c}`), { data: g })), g.event === f.StreamDone && o();
|
|
997
998
|
}
|
|
998
999
|
}
|
|
999
1000
|
};
|
|
1000
1001
|
}
|
|
1001
|
-
function
|
|
1002
|
-
const o =
|
|
1002
|
+
function rn(e, t, i, r) {
|
|
1003
|
+
const o = Ae(e, `${t}/agents/${i}`, r);
|
|
1003
1004
|
return {
|
|
1004
1005
|
createStream(a, s) {
|
|
1005
1006
|
return o.post("/streams", a, { signal: s });
|
|
@@ -1035,8 +1036,8 @@ function nn(e, t, i, r) {
|
|
|
1035
1036
|
}
|
|
1036
1037
|
};
|
|
1037
1038
|
}
|
|
1038
|
-
const
|
|
1039
|
-
function
|
|
1039
|
+
const an = (window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection).bind(window);
|
|
1040
|
+
function Je(e) {
|
|
1040
1041
|
switch (e) {
|
|
1041
1042
|
case "connected":
|
|
1042
1043
|
return T.Connected;
|
|
@@ -1056,7 +1057,7 @@ function Ne(e) {
|
|
|
1056
1057
|
return T.New;
|
|
1057
1058
|
}
|
|
1058
1059
|
}
|
|
1059
|
-
const
|
|
1060
|
+
const on = (e) => (t) => {
|
|
1060
1061
|
const [i, r = ""] = t.split(/:(.+)/);
|
|
1061
1062
|
try {
|
|
1062
1063
|
const o = JSON.parse(r);
|
|
@@ -1065,16 +1066,16 @@ const an = (e) => (t) => {
|
|
|
1065
1066
|
return e("Failed to parse data channel message, returning data as string", { subject: i, rawData: r, error: o }), { subject: i, data: r };
|
|
1066
1067
|
}
|
|
1067
1068
|
};
|
|
1068
|
-
function
|
|
1069
|
+
function sn({
|
|
1069
1070
|
statsSignal: e,
|
|
1070
1071
|
dataChannelSignal: t,
|
|
1071
1072
|
onVideoStateChange: i,
|
|
1072
1073
|
report: r,
|
|
1073
1074
|
log: o
|
|
1074
1075
|
}) {
|
|
1075
|
-
e ===
|
|
1076
|
+
e === C.Start && t === C.Start ? (o("CALLBACK: onVideoStateChange(Start)"), i == null || i(C.Start)) : e === C.Stop && t === C.Stop && (o("CALLBACK: onVideoStateChange(Stop)"), i == null || i(C.Stop, r));
|
|
1076
1077
|
}
|
|
1077
|
-
function
|
|
1078
|
+
function cn({
|
|
1078
1079
|
statsSignal: e,
|
|
1079
1080
|
dataChannelSignal: t,
|
|
1080
1081
|
onVideoStateChange: i,
|
|
@@ -1082,9 +1083,9 @@ function sn({
|
|
|
1082
1083
|
report: o,
|
|
1083
1084
|
log: a
|
|
1084
1085
|
}) {
|
|
1085
|
-
e ===
|
|
1086
|
+
e === C.Start ? (a("CALLBACK: onVideoStateChange(Start)"), i == null || i(C.Start)) : e === C.Stop && (a("CALLBACK: onVideoStateChange(Stop)"), i == null || i(C.Stop, o)), t === C.Start ? r == null || r(O.Talking) : t === C.Stop && (r == null || r(O.Idle));
|
|
1086
1087
|
}
|
|
1087
|
-
function
|
|
1088
|
+
function Ue({
|
|
1088
1089
|
statsSignal: e,
|
|
1089
1090
|
dataChannelSignal: t,
|
|
1090
1091
|
onVideoStateChange: i,
|
|
@@ -1093,7 +1094,7 @@ function Ve({
|
|
|
1093
1094
|
report: a,
|
|
1094
1095
|
log: s
|
|
1095
1096
|
}) {
|
|
1096
|
-
o === re.Legacy ?
|
|
1097
|
+
o === re.Legacy ? sn({ statsSignal: e, dataChannelSignal: t, onVideoStateChange: i, report: a, log: s }) : o === re.Fluent && cn({
|
|
1097
1098
|
statsSignal: e,
|
|
1098
1099
|
dataChannelSignal: t,
|
|
1099
1100
|
onVideoStateChange: i,
|
|
@@ -1102,189 +1103,189 @@ function Ve({
|
|
|
1102
1103
|
log: s
|
|
1103
1104
|
});
|
|
1104
1105
|
}
|
|
1105
|
-
async function
|
|
1106
|
+
async function dn(e, t, { debug: i = !1, callbacks: r, auth: o, baseURL: a = pe, analytics: s }, d) {
|
|
1106
1107
|
var ie;
|
|
1107
|
-
const n =
|
|
1108
|
-
let
|
|
1109
|
-
const { startConnection: P, sendStreamRequest:
|
|
1108
|
+
const n = Ze(i, "WebRTCStreamingManager"), c = on(n);
|
|
1109
|
+
let g = !1, w = !1, h = C.Stop, f = C.Stop;
|
|
1110
|
+
const { startConnection: P, sendStreamRequest: J, close: D, createStream: k, addIceCandidate: _ } = rn(
|
|
1110
1111
|
o,
|
|
1111
1112
|
a,
|
|
1112
1113
|
e,
|
|
1113
1114
|
r.onError
|
|
1114
1115
|
), {
|
|
1115
1116
|
id: I,
|
|
1116
|
-
offer:
|
|
1117
|
-
ice_servers:
|
|
1118
|
-
session_id:
|
|
1119
|
-
fluent:
|
|
1120
|
-
interrupt_enabled:
|
|
1121
|
-
triggers_enabled:
|
|
1122
|
-
} = await
|
|
1123
|
-
(ie = r.onStreamCreated) == null || ie.call(r, { stream_id: I, session_id:
|
|
1124
|
-
const u = new
|
|
1125
|
-
if (!
|
|
1117
|
+
offer: F,
|
|
1118
|
+
ice_servers: $,
|
|
1119
|
+
session_id: H,
|
|
1120
|
+
fluent: Z,
|
|
1121
|
+
interrupt_enabled: se,
|
|
1122
|
+
triggers_enabled: N
|
|
1123
|
+
} = await k(t, d);
|
|
1124
|
+
(ie = r.onStreamCreated) == null || ie.call(r, { stream_id: I, session_id: H, agent_id: e });
|
|
1125
|
+
const u = new an({ iceServers: $ }), S = u.createDataChannel("JanusDataChannel");
|
|
1126
|
+
if (!H)
|
|
1126
1127
|
throw new Error("Could not create session_id");
|
|
1127
|
-
const
|
|
1128
|
+
const R = Z ? re.Fluent : re.Legacy;
|
|
1128
1129
|
s.enrich({
|
|
1129
|
-
"stream-type":
|
|
1130
|
+
"stream-type": R
|
|
1130
1131
|
});
|
|
1131
|
-
const z = t.stream_warmup && !
|
|
1132
|
-
var
|
|
1133
|
-
|
|
1134
|
-
}, K =
|
|
1132
|
+
const z = t.stream_warmup && !Z, b = () => g, A = () => {
|
|
1133
|
+
var y;
|
|
1134
|
+
g = !0, w && (n("CALLBACK: onConnectionStateChange(Connected)"), (y = r.onConnectionStateChange) == null || y.call(r, T.Connected));
|
|
1135
|
+
}, K = et(
|
|
1135
1136
|
() => u.getStats(),
|
|
1136
1137
|
b,
|
|
1137
|
-
|
|
1138
|
-
(
|
|
1139
|
-
statsSignal:
|
|
1140
|
-
dataChannelSignal:
|
|
1138
|
+
A,
|
|
1139
|
+
(y, m) => Ue({
|
|
1140
|
+
statsSignal: f = y,
|
|
1141
|
+
dataChannelSignal: R === re.Legacy ? h : void 0,
|
|
1141
1142
|
onVideoStateChange: r.onVideoStateChange,
|
|
1142
1143
|
onAgentActivityStateChange: r.onAgentActivityStateChange,
|
|
1143
|
-
report:
|
|
1144
|
-
streamType:
|
|
1144
|
+
report: m,
|
|
1145
|
+
streamType: R,
|
|
1145
1146
|
log: n
|
|
1146
1147
|
}),
|
|
1147
|
-
(
|
|
1148
|
-
var
|
|
1149
|
-
return (
|
|
1148
|
+
(y) => {
|
|
1149
|
+
var m;
|
|
1150
|
+
return (m = r.onConnectivityStateChange) == null ? void 0 : m.call(r, y);
|
|
1150
1151
|
}
|
|
1151
1152
|
);
|
|
1152
|
-
K.start(), u.onicecandidate = (
|
|
1153
|
-
var
|
|
1154
|
-
n("peerConnection.onicecandidate",
|
|
1153
|
+
K.start(), u.onicecandidate = (y) => {
|
|
1154
|
+
var m;
|
|
1155
|
+
n("peerConnection.onicecandidate", y);
|
|
1155
1156
|
try {
|
|
1156
|
-
|
|
1157
|
+
y.candidate && y.candidate.sdpMid && y.candidate.sdpMLineIndex !== null ? _(
|
|
1157
1158
|
I,
|
|
1158
1159
|
{
|
|
1159
|
-
candidate:
|
|
1160
|
-
sdpMid:
|
|
1161
|
-
sdpMLineIndex:
|
|
1160
|
+
candidate: y.candidate.candidate,
|
|
1161
|
+
sdpMid: y.candidate.sdpMid,
|
|
1162
|
+
sdpMLineIndex: y.candidate.sdpMLineIndex
|
|
1162
1163
|
},
|
|
1163
|
-
|
|
1164
|
+
H,
|
|
1164
1165
|
d
|
|
1165
|
-
) :
|
|
1166
|
-
} catch (
|
|
1167
|
-
(
|
|
1166
|
+
) : _(I, { candidate: null }, H, d);
|
|
1167
|
+
} catch (E) {
|
|
1168
|
+
(m = r.onError) == null || m.call(r, E, { streamId: I });
|
|
1168
1169
|
}
|
|
1169
|
-
},
|
|
1170
|
-
|
|
1170
|
+
}, S.onopen = () => {
|
|
1171
|
+
w = !0, (!z || g) && A();
|
|
1171
1172
|
};
|
|
1172
|
-
const
|
|
1173
|
-
var
|
|
1174
|
-
(
|
|
1173
|
+
const q = (y) => {
|
|
1174
|
+
var m;
|
|
1175
|
+
(m = r.onVideoIdChange) == null || m.call(r, y);
|
|
1175
1176
|
};
|
|
1176
|
-
function
|
|
1177
|
-
if (
|
|
1178
|
-
const
|
|
1179
|
-
|
|
1177
|
+
function W(y, m) {
|
|
1178
|
+
if (y === L.StreamStarted && typeof m == "object" && "metadata" in m) {
|
|
1179
|
+
const E = m.metadata;
|
|
1180
|
+
q(E.videoId);
|
|
1180
1181
|
}
|
|
1181
|
-
|
|
1182
|
-
statsSignal:
|
|
1183
|
-
dataChannelSignal:
|
|
1182
|
+
y === L.StreamDone && q(null), h = y === L.StreamStarted ? C.Start : C.Stop, Ue({
|
|
1183
|
+
statsSignal: R === re.Legacy ? f : void 0,
|
|
1184
|
+
dataChannelSignal: h,
|
|
1184
1185
|
onVideoStateChange: r.onVideoStateChange,
|
|
1185
1186
|
onAgentActivityStateChange: r.onAgentActivityStateChange,
|
|
1186
|
-
streamType:
|
|
1187
|
+
streamType: R,
|
|
1187
1188
|
log: n
|
|
1188
1189
|
});
|
|
1189
1190
|
}
|
|
1190
|
-
function
|
|
1191
|
+
function j(y, m) {
|
|
1191
1192
|
var G;
|
|
1192
|
-
const
|
|
1193
|
-
|
|
1193
|
+
const E = typeof m == "string" ? m : m == null ? void 0 : m.metadata;
|
|
1194
|
+
E && s.enrich({ streamMetadata: E }), (G = r.onStreamReady) == null || G.call(r);
|
|
1194
1195
|
}
|
|
1195
1196
|
const B = {
|
|
1196
|
-
[
|
|
1197
|
-
[
|
|
1198
|
-
[
|
|
1197
|
+
[L.StreamStarted]: W,
|
|
1198
|
+
[L.StreamDone]: W,
|
|
1199
|
+
[L.StreamReady]: j
|
|
1199
1200
|
};
|
|
1200
|
-
|
|
1201
|
+
S.onmessage = (y) => {
|
|
1201
1202
|
var G;
|
|
1202
|
-
const { subject:
|
|
1203
|
-
(G = B[
|
|
1203
|
+
const { subject: m, data: E } = c(y.data);
|
|
1204
|
+
(G = B[m]) == null || G.call(B, m, E);
|
|
1204
1205
|
}, u.oniceconnectionstatechange = () => {
|
|
1205
|
-
var
|
|
1206
|
+
var m;
|
|
1206
1207
|
n("peerConnection.oniceconnectionstatechange => " + u.iceConnectionState);
|
|
1207
|
-
const
|
|
1208
|
-
|
|
1209
|
-
}, u.ontrack = (
|
|
1210
|
-
var
|
|
1211
|
-
n("peerConnection.ontrack",
|
|
1212
|
-
}, await u.setRemoteDescription(
|
|
1208
|
+
const y = Je(u.iceConnectionState);
|
|
1209
|
+
y !== T.Connected && ((m = r.onConnectionStateChange) == null || m.call(r, y));
|
|
1210
|
+
}, u.ontrack = (y) => {
|
|
1211
|
+
var m;
|
|
1212
|
+
n("peerConnection.ontrack", y), n("CALLBACK: onSrcObjectReady"), (m = r.onSrcObjectReady) == null || m.call(r, y.streams[0]);
|
|
1213
|
+
}, await u.setRemoteDescription(F), n("set remote description OK");
|
|
1213
1214
|
const Y = await u.createAnswer();
|
|
1214
|
-
return n("create answer OK"), await u.setLocalDescription(Y), n("set local description OK"), await P(I, Y,
|
|
1215
|
+
return n("create answer OK"), await u.setLocalDescription(Y), n("set local description OK"), await P(I, Y, H, d), n("start connection OK"), {
|
|
1215
1216
|
/**
|
|
1216
1217
|
* Method to send request to server to get clip or talk depend on you payload
|
|
1217
1218
|
* @param payload
|
|
1218
1219
|
*/
|
|
1219
|
-
speak(
|
|
1220
|
-
return
|
|
1220
|
+
speak(y) {
|
|
1221
|
+
return J(I, H, y);
|
|
1221
1222
|
},
|
|
1222
1223
|
/**
|
|
1223
1224
|
* Method to close RTC connection
|
|
1224
1225
|
*/
|
|
1225
1226
|
async disconnect() {
|
|
1226
|
-
var
|
|
1227
|
+
var y;
|
|
1227
1228
|
if (I) {
|
|
1228
|
-
const
|
|
1229
|
+
const m = Je(u.iceConnectionState);
|
|
1229
1230
|
if (u) {
|
|
1230
|
-
if (
|
|
1231
|
+
if (m === T.New) {
|
|
1231
1232
|
K.stop();
|
|
1232
1233
|
return;
|
|
1233
1234
|
}
|
|
1234
1235
|
u.close(), u.oniceconnectionstatechange = null, u.onnegotiationneeded = null, u.onicecandidate = null, u.ontrack = null;
|
|
1235
1236
|
}
|
|
1236
1237
|
try {
|
|
1237
|
-
|
|
1238
|
+
m === T.Connected && await D(I, H).catch((E) => {
|
|
1238
1239
|
});
|
|
1239
|
-
} catch (
|
|
1240
|
-
n("Error on close stream connection",
|
|
1240
|
+
} catch (E) {
|
|
1241
|
+
n("Error on close stream connection", E);
|
|
1241
1242
|
}
|
|
1242
|
-
(
|
|
1243
|
+
(y = r.onAgentActivityStateChange) == null || y.call(r, O.Idle), K.stop();
|
|
1243
1244
|
}
|
|
1244
1245
|
},
|
|
1245
1246
|
/**
|
|
1246
1247
|
* Method to send data channel messages to the server
|
|
1247
1248
|
*/
|
|
1248
|
-
sendDataChannelMessage(
|
|
1249
|
-
var
|
|
1250
|
-
if (!
|
|
1251
|
-
n("Data channel is not ready for sending messages"), (
|
|
1249
|
+
sendDataChannelMessage(y) {
|
|
1250
|
+
var m, E;
|
|
1251
|
+
if (!g || S.readyState !== "open") {
|
|
1252
|
+
n("Data channel is not ready for sending messages"), (m = r.onError) == null || m.call(r, new Error("Data channel is not ready for sending messages"), {
|
|
1252
1253
|
streamId: I
|
|
1253
1254
|
});
|
|
1254
1255
|
return;
|
|
1255
1256
|
}
|
|
1256
1257
|
try {
|
|
1257
|
-
|
|
1258
|
+
S.send(y);
|
|
1258
1259
|
} catch (G) {
|
|
1259
|
-
n("Error sending data channel message", G), (
|
|
1260
|
+
n("Error sending data channel message", G), (E = r.onError) == null || E.call(r, G, { streamId: I });
|
|
1260
1261
|
}
|
|
1261
1262
|
},
|
|
1262
1263
|
/**
|
|
1263
1264
|
* Session identifier information, should be returned in the body of all streaming requests
|
|
1264
1265
|
*/
|
|
1265
|
-
sessionId:
|
|
1266
|
+
sessionId: H,
|
|
1266
1267
|
/**
|
|
1267
1268
|
* Id of current RTC stream
|
|
1268
1269
|
*/
|
|
1269
1270
|
streamId: I,
|
|
1270
|
-
streamType:
|
|
1271
|
-
interruptAvailable:
|
|
1272
|
-
triggersAvailable:
|
|
1271
|
+
streamType: R,
|
|
1272
|
+
interruptAvailable: se ?? !1,
|
|
1273
|
+
triggersAvailable: N ?? !1
|
|
1273
1274
|
};
|
|
1274
1275
|
}
|
|
1275
|
-
var
|
|
1276
|
-
async function
|
|
1276
|
+
var Te = /* @__PURE__ */ ((e) => (e.V1 = "v1", e.V2 = "v2", e))(Te || {});
|
|
1277
|
+
async function un(e, t, i, r) {
|
|
1277
1278
|
const o = e.id;
|
|
1278
1279
|
switch (t.version) {
|
|
1279
1280
|
case "v1": {
|
|
1280
1281
|
const { version: a, ...s } = t;
|
|
1281
|
-
return
|
|
1282
|
+
return dn(o, s, i, r);
|
|
1282
1283
|
}
|
|
1283
1284
|
case "v2": {
|
|
1284
1285
|
const { version: a, ...s } = t;
|
|
1285
1286
|
switch (s.transport_provider) {
|
|
1286
1287
|
case ke.Livekit:
|
|
1287
|
-
const { createLiveKitStreamingManager: d } = await Promise.resolve().then(() =>
|
|
1288
|
+
const { createLiveKitStreamingManager: d } = await Promise.resolve().then(() => Ot);
|
|
1288
1289
|
return d(o, s, i);
|
|
1289
1290
|
default:
|
|
1290
1291
|
throw new Error(`Unsupported transport provider: ${s.transport_provider}`);
|
|
@@ -1294,8 +1295,8 @@ async function dn(e, t, i, r) {
|
|
|
1294
1295
|
throw new Error(`Invalid stream version: ${t.version}`);
|
|
1295
1296
|
}
|
|
1296
1297
|
}
|
|
1297
|
-
const
|
|
1298
|
-
function
|
|
1298
|
+
const ln = "cht";
|
|
1299
|
+
function fn() {
|
|
1299
1300
|
return {
|
|
1300
1301
|
transport_provider: ke.Livekit
|
|
1301
1302
|
};
|
|
@@ -1313,17 +1314,17 @@ function mn(e) {
|
|
|
1313
1314
|
fluent: t == null ? void 0 : t.fluent
|
|
1314
1315
|
}, ...i && { end_user_data: i } };
|
|
1315
1316
|
}
|
|
1316
|
-
function
|
|
1317
|
-
return
|
|
1317
|
+
function gn(e, t) {
|
|
1318
|
+
return _e(e.presenter.type) ? { version: Te.V2, ...fn() } : { version: Te.V1, ...mn(t) };
|
|
1318
1319
|
}
|
|
1319
|
-
function
|
|
1320
|
+
function hn(e, t, i) {
|
|
1320
1321
|
i.track("agent-connection-state-change", { state: e, ...t && { reason: t } });
|
|
1321
1322
|
}
|
|
1322
|
-
function hn(e, t, i, r, o) {
|
|
1323
|
-
o === re.Fluent ? pn(e, t, i, r, o) : yn(e, t, i, r, o);
|
|
1324
|
-
}
|
|
1325
1323
|
function pn(e, t, i, r, o) {
|
|
1326
|
-
|
|
1324
|
+
o === re.Fluent ? wn(e, t, i, r, o) : vn(e, t, i, r, o);
|
|
1325
|
+
}
|
|
1326
|
+
function wn(e, t, i, r, o) {
|
|
1327
|
+
e === C.Start ? r.track("stream-session", { event: "start", "stream-type": o }) : e === C.Stop && r.track("stream-session", {
|
|
1327
1328
|
event: "stop",
|
|
1328
1329
|
is_greenscreen: t.presenter.type === "clip" && t.presenter.is_greenscreen,
|
|
1329
1330
|
background: t.presenter.type === "clip" && t.presenter.background,
|
|
@@ -1331,13 +1332,13 @@ function pn(e, t, i, r, o) {
|
|
|
1331
1332
|
...i
|
|
1332
1333
|
});
|
|
1333
1334
|
}
|
|
1334
|
-
function
|
|
1335
|
-
|
|
1335
|
+
function yn(e, t, i, r) {
|
|
1336
|
+
te.get() <= 0 || (e === C.Start ? i.linkTrack(
|
|
1336
1337
|
"agent-video",
|
|
1337
|
-
{ event: "start", latency:
|
|
1338
|
+
{ event: "start", latency: te.get(!0), "stream-type": r },
|
|
1338
1339
|
"start",
|
|
1339
|
-
[
|
|
1340
|
-
) : e ===
|
|
1340
|
+
[L.StreamVideoCreated]
|
|
1341
|
+
) : e === C.Stop && i.linkTrack(
|
|
1341
1342
|
"agent-video",
|
|
1342
1343
|
{
|
|
1343
1344
|
event: "stop",
|
|
@@ -1346,16 +1347,16 @@ function wn(e, t, i, r) {
|
|
|
1346
1347
|
"stream-type": r
|
|
1347
1348
|
},
|
|
1348
1349
|
"done",
|
|
1349
|
-
[
|
|
1350
|
+
[L.StreamVideoDone]
|
|
1350
1351
|
));
|
|
1351
1352
|
}
|
|
1352
|
-
function
|
|
1353
|
-
|
|
1353
|
+
function vn(e, t, i, r, o) {
|
|
1354
|
+
te.get() <= 0 || (e === C.Start ? r.linkTrack(
|
|
1354
1355
|
"agent-video",
|
|
1355
|
-
{ event: "start", latency:
|
|
1356
|
+
{ event: "start", latency: te.get(!0), "stream-type": o },
|
|
1356
1357
|
"start",
|
|
1357
|
-
[
|
|
1358
|
-
) : e ===
|
|
1358
|
+
[L.StreamVideoCreated]
|
|
1359
|
+
) : e === C.Stop && r.linkTrack(
|
|
1359
1360
|
"agent-video",
|
|
1360
1361
|
{
|
|
1361
1362
|
event: "stop",
|
|
@@ -1365,17 +1366,17 @@ function yn(e, t, i, r, o) {
|
|
|
1365
1366
|
...i
|
|
1366
1367
|
},
|
|
1367
1368
|
"done",
|
|
1368
|
-
[
|
|
1369
|
+
[L.StreamVideoDone]
|
|
1369
1370
|
));
|
|
1370
1371
|
}
|
|
1371
|
-
function
|
|
1372
|
-
return
|
|
1372
|
+
function We(e, t, i, r) {
|
|
1373
|
+
return te.reset(), Ne.update(), new Promise(async (o, a) => {
|
|
1373
1374
|
try {
|
|
1374
1375
|
let s, d = !1;
|
|
1375
|
-
const n =
|
|
1376
|
+
const n = gn(e, t);
|
|
1376
1377
|
i.enrich({
|
|
1377
1378
|
"stream-version": n.version.toString()
|
|
1378
|
-
}), s = await
|
|
1379
|
+
}), s = await un(
|
|
1379
1380
|
e,
|
|
1380
1381
|
n,
|
|
1381
1382
|
{
|
|
@@ -1383,31 +1384,31 @@ function Je(e, t, i, r) {
|
|
|
1383
1384
|
analytics: i,
|
|
1384
1385
|
callbacks: {
|
|
1385
1386
|
...t.callbacks,
|
|
1386
|
-
onConnectionStateChange: (c,
|
|
1387
|
-
var
|
|
1388
|
-
(
|
|
1387
|
+
onConnectionStateChange: (c, g) => {
|
|
1388
|
+
var w, h;
|
|
1389
|
+
(h = (w = t.callbacks).onConnectionStateChange) == null || h.call(w, c), hn(c, g, i), c === T.Connected && (s ? o(s) : d = !0);
|
|
1389
1390
|
},
|
|
1390
|
-
onVideoStateChange: (c,
|
|
1391
|
-
var
|
|
1392
|
-
(
|
|
1391
|
+
onVideoStateChange: (c, g) => {
|
|
1392
|
+
var w, h;
|
|
1393
|
+
(h = (w = t.callbacks).onVideoStateChange) == null || h.call(w, c), pn(
|
|
1393
1394
|
c,
|
|
1394
1395
|
e,
|
|
1395
|
-
|
|
1396
|
+
g,
|
|
1396
1397
|
i,
|
|
1397
1398
|
s.streamType
|
|
1398
1399
|
);
|
|
1399
1400
|
},
|
|
1400
1401
|
onAgentActivityStateChange: (c) => {
|
|
1401
|
-
var
|
|
1402
|
-
(
|
|
1403
|
-
c ===
|
|
1402
|
+
var g, w;
|
|
1403
|
+
(w = (g = t.callbacks).onAgentActivityStateChange) == null || w.call(g, c), c === O.Talking ? Me.update() : Me.reset(), yn(
|
|
1404
|
+
c === O.Talking ? C.Start : C.Stop,
|
|
1404
1405
|
e,
|
|
1405
1406
|
i,
|
|
1406
1407
|
s.streamType
|
|
1407
1408
|
);
|
|
1408
1409
|
},
|
|
1409
1410
|
onStreamReady: () => {
|
|
1410
|
-
const c =
|
|
1411
|
+
const c = Ne.get(!0);
|
|
1411
1412
|
i.track("agent-chat", { event: "ready", latency: c });
|
|
1412
1413
|
}
|
|
1413
1414
|
}
|
|
@@ -1419,50 +1420,50 @@ function Je(e, t, i, r) {
|
|
|
1419
1420
|
}
|
|
1420
1421
|
});
|
|
1421
1422
|
}
|
|
1422
|
-
async function
|
|
1423
|
-
var
|
|
1423
|
+
async function Cn(e, t, i, r, o) {
|
|
1424
|
+
var g, w, h, f;
|
|
1424
1425
|
const a = async () => {
|
|
1425
|
-
if (
|
|
1426
|
-
const P = await
|
|
1426
|
+
if (_e(e.presenter.type)) {
|
|
1427
|
+
const P = await We(e, t, r), J = `${ln}_${P.sessionId}`, D = (/* @__PURE__ */ new Date()).toISOString();
|
|
1427
1428
|
return { chatResult: {
|
|
1428
1429
|
chatMode: x.Functional,
|
|
1429
1430
|
chat: {
|
|
1430
|
-
id:
|
|
1431
|
+
id: J,
|
|
1431
1432
|
agent_id: e.id,
|
|
1432
1433
|
owner_id: e.owner_id ?? "",
|
|
1433
|
-
created:
|
|
1434
|
-
modified:
|
|
1435
|
-
agent_id__created_at:
|
|
1436
|
-
agent_id__modified_at:
|
|
1434
|
+
created: D,
|
|
1435
|
+
modified: D,
|
|
1436
|
+
agent_id__created_at: D,
|
|
1437
|
+
agent_id__modified_at: D,
|
|
1437
1438
|
chat_mode: x.Functional,
|
|
1438
1439
|
messages: []
|
|
1439
1440
|
}
|
|
1440
1441
|
}, streamingManager: P };
|
|
1441
1442
|
} else {
|
|
1442
|
-
const P = new AbortController(),
|
|
1443
|
-
let
|
|
1443
|
+
const P = new AbortController(), J = P.signal;
|
|
1444
|
+
let D;
|
|
1444
1445
|
try {
|
|
1445
|
-
const
|
|
1446
|
+
const k = Ge(
|
|
1446
1447
|
e,
|
|
1447
1448
|
i,
|
|
1448
1449
|
r,
|
|
1449
1450
|
t.mode,
|
|
1450
1451
|
t.persistentChat,
|
|
1451
1452
|
o
|
|
1452
|
-
),
|
|
1453
|
-
return { chatResult: I, streamingManager:
|
|
1454
|
-
} catch (
|
|
1455
|
-
throw P.abort(),
|
|
1456
|
-
}),
|
|
1453
|
+
), _ = We(e, t, r, J).then(($) => (D = $, $)), [I, F] = await Promise.all([k, _]);
|
|
1454
|
+
return { chatResult: I, streamingManager: F };
|
|
1455
|
+
} catch (k) {
|
|
1456
|
+
throw P.abort(), D && await D.disconnect().catch(() => {
|
|
1457
|
+
}), k;
|
|
1457
1458
|
}
|
|
1458
1459
|
}
|
|
1459
1460
|
}, { chatResult: s, streamingManager: d } = await a(), { chat: n, chatMode: c } = s;
|
|
1460
|
-
return c && t.mode !== void 0 && c !== t.mode && (t.mode = c, (
|
|
1461
|
+
return c && t.mode !== void 0 && c !== t.mode && (t.mode = c, (w = (g = t.callbacks).onModeChange) == null || w.call(g, c), c !== x.Functional) ? ((f = (h = t.callbacks).onError) == null || f.call(h, new ot(c)), d == null || d.disconnect(), { chat: n }) : { chat: n, streamingManager: d };
|
|
1461
1462
|
}
|
|
1462
|
-
async function
|
|
1463
|
-
var
|
|
1463
|
+
async function Rn(e, t) {
|
|
1464
|
+
var H, Z, se, N;
|
|
1464
1465
|
let i = !0, r = null;
|
|
1465
|
-
const o = t.mixpanelKey ||
|
|
1466
|
+
const o = t.mixpanelKey || Ct, a = t.wsURL || vt, s = t.baseURL || pe, d = t.mode || x.Functional, n = {
|
|
1466
1467
|
messages: [],
|
|
1467
1468
|
chatMode: d
|
|
1468
1469
|
}, c = Pt({
|
|
@@ -1471,91 +1472,91 @@ async function kn(e, t) {
|
|
|
1471
1472
|
isEnabled: t.enableAnalitics,
|
|
1472
1473
|
externalId: t.externalId,
|
|
1473
1474
|
mixpanelAdditionalProperties: t.mixpanelAdditionalProperties
|
|
1474
|
-
}),
|
|
1475
|
-
|
|
1476
|
-
c.track("agent-sdk", { event: "init" },
|
|
1475
|
+
}), g = Date.now();
|
|
1476
|
+
Ke(() => {
|
|
1477
|
+
c.track("agent-sdk", { event: "init" }, g);
|
|
1477
1478
|
});
|
|
1478
|
-
const
|
|
1479
|
-
t.debug = t.debug || ((
|
|
1480
|
-
const
|
|
1481
|
-
c.enrich(
|
|
1482
|
-
const { onMessage: P, clearQueue:
|
|
1479
|
+
const w = Mt(t.auth, s, t.callbacks.onError, t.externalId), h = await w.getById(e);
|
|
1480
|
+
t.debug = t.debug || ((H = h == null ? void 0 : h.advanced_settings) == null ? void 0 : H.ui_debug_mode);
|
|
1481
|
+
const f = _e(h.presenter.type);
|
|
1482
|
+
c.enrich(Tt(h));
|
|
1483
|
+
const { onMessage: P, clearQueue: J } = nn(
|
|
1483
1484
|
c,
|
|
1484
1485
|
n,
|
|
1485
1486
|
t,
|
|
1486
|
-
|
|
1487
|
+
h,
|
|
1487
1488
|
() => {
|
|
1488
1489
|
var u;
|
|
1489
1490
|
return (u = n.socketManager) == null ? void 0 : u.disconnect();
|
|
1490
1491
|
}
|
|
1491
1492
|
);
|
|
1492
|
-
n.messages =
|
|
1493
|
-
const
|
|
1493
|
+
n.messages = jt(t.initialMessages), (se = (Z = t.callbacks).onNewMessage) == null || se.call(Z, [...n.messages], "answer");
|
|
1494
|
+
const D = (u) => {
|
|
1494
1495
|
r = u;
|
|
1495
|
-
},
|
|
1496
|
-
var
|
|
1497
|
-
const
|
|
1496
|
+
}, k = ({ type: u }) => {
|
|
1497
|
+
var R, z, b;
|
|
1498
|
+
const S = n.messages[n.messages.length - 1];
|
|
1498
1499
|
c.track("agent-video-interrupt", {
|
|
1499
1500
|
type: u || "click",
|
|
1500
|
-
video_duration_to_interrupt:
|
|
1501
|
-
message_duration_to_interrupt:
|
|
1502
|
-
}),
|
|
1503
|
-
},
|
|
1504
|
-
|
|
1505
|
-
c.track("agent-sdk", { event: "loaded", ...
|
|
1501
|
+
video_duration_to_interrupt: Me.get(!0),
|
|
1502
|
+
message_duration_to_interrupt: te.get(!0)
|
|
1503
|
+
}), S.interrupted = !0, (z = (R = t.callbacks).onNewMessage) == null || z.call(R, [...n.messages], "answer"), f ? Qt(n.streamingManager) : (Ht(n.streamingManager, (b = n.streamingManager) == null ? void 0 : b.streamType, r), qt(n.streamingManager, r));
|
|
1504
|
+
}, _ = Date.now();
|
|
1505
|
+
Ke(() => {
|
|
1506
|
+
c.track("agent-sdk", { event: "loaded", ...It(h) }, _);
|
|
1506
1507
|
});
|
|
1507
1508
|
async function I(u) {
|
|
1508
|
-
var K,
|
|
1509
|
-
(
|
|
1510
|
-
const
|
|
1509
|
+
var K, q, W, j, B, Y, ie;
|
|
1510
|
+
(q = (K = t.callbacks).onConnectionStateChange) == null || q.call(K, T.Connecting), te.reset(), u && !i && (delete n.chat, (j = (W = t.callbacks).onNewMessage) == null || j.call(W, [...n.messages], "answer"));
|
|
1511
|
+
const S = d === x.DirectPlayback || f ? Promise.resolve(void 0) : Gt(
|
|
1511
1512
|
t.auth,
|
|
1512
1513
|
a,
|
|
1513
1514
|
{ onMessage: P, onError: t.callbacks.onError },
|
|
1514
1515
|
t.externalId
|
|
1515
|
-
),
|
|
1516
|
-
() =>
|
|
1517
|
-
|
|
1516
|
+
), R = De(
|
|
1517
|
+
() => Cn(
|
|
1518
|
+
h,
|
|
1518
1519
|
{
|
|
1519
1520
|
...t,
|
|
1520
1521
|
mode: d,
|
|
1521
1522
|
callbacks: {
|
|
1522
1523
|
...t.callbacks,
|
|
1523
|
-
onVideoIdChange:
|
|
1524
|
+
onVideoIdChange: D,
|
|
1524
1525
|
onMessage: P,
|
|
1525
|
-
onInterruptDetected:
|
|
1526
|
+
onInterruptDetected: k
|
|
1526
1527
|
}
|
|
1527
1528
|
},
|
|
1528
|
-
|
|
1529
|
+
w,
|
|
1529
1530
|
c,
|
|
1530
1531
|
n.chat
|
|
1531
1532
|
),
|
|
1532
1533
|
{
|
|
1533
1534
|
limit: 3,
|
|
1534
|
-
timeout:
|
|
1535
|
+
timeout: wt,
|
|
1535
1536
|
timeoutErrorMessage: "Timeout initializing the stream",
|
|
1536
|
-
shouldRetryFn: (
|
|
1537
|
+
shouldRetryFn: (y) => (y == null ? void 0 : y.message) !== "Could not connect" && y.status !== 429 && (y == null ? void 0 : y.message) !== "InsufficientCreditsError",
|
|
1537
1538
|
delayMs: 1e3
|
|
1538
1539
|
}
|
|
1539
|
-
).catch((
|
|
1540
|
-
var
|
|
1541
|
-
throw
|
|
1542
|
-
}), [z, { streamingManager: b, chat:
|
|
1543
|
-
|
|
1544
|
-
chatId:
|
|
1540
|
+
).catch((y) => {
|
|
1541
|
+
var m, E;
|
|
1542
|
+
throw $(x.Maintenance), (E = (m = t.callbacks).onConnectionStateChange) == null || E.call(m, T.Fail), y;
|
|
1543
|
+
}), [z, { streamingManager: b, chat: A }] = await Promise.all([S, R]);
|
|
1544
|
+
A && A.id !== ((B = n.chat) == null ? void 0 : B.id) && ((ie = (Y = t.callbacks).onNewChat) == null || ie.call(Y, A.id)), n.streamingManager = b, n.socketManager = z, n.chat = A, i = !1, c.enrich({
|
|
1545
|
+
chatId: A == null ? void 0 : A.id,
|
|
1545
1546
|
streamId: b == null ? void 0 : b.streamId,
|
|
1546
1547
|
mode: n.chatMode
|
|
1547
|
-
}),
|
|
1548
|
+
}), $((A == null ? void 0 : A.chat_mode) ?? d);
|
|
1548
1549
|
}
|
|
1549
|
-
async function
|
|
1550
|
-
var u,
|
|
1551
|
-
(u = n.socketManager) == null || u.disconnect(), await ((
|
|
1550
|
+
async function F() {
|
|
1551
|
+
var u, S, R, z;
|
|
1552
|
+
(u = n.socketManager) == null || u.disconnect(), await ((S = n.streamingManager) == null ? void 0 : S.disconnect()), delete n.streamingManager, delete n.socketManager, (z = (R = t.callbacks).onConnectionStateChange) == null || z.call(R, T.Disconnected);
|
|
1552
1553
|
}
|
|
1553
|
-
async function
|
|
1554
|
-
var
|
|
1555
|
-
u !== n.chatMode && (c.track("agent-mode-change", { mode: u }), n.chatMode = u, n.chatMode !== x.Functional && await
|
|
1554
|
+
async function $(u) {
|
|
1555
|
+
var S, R;
|
|
1556
|
+
u !== n.chatMode && (c.track("agent-mode-change", { mode: u }), n.chatMode = u, n.chatMode !== x.Functional && await F(), (R = (S = t.callbacks).onModeChange) == null || R.call(S, u));
|
|
1556
1557
|
}
|
|
1557
1558
|
return {
|
|
1558
|
-
agent:
|
|
1559
|
+
agent: h,
|
|
1559
1560
|
getStreamType: () => {
|
|
1560
1561
|
var u;
|
|
1561
1562
|
return (u = n.streamingManager) == null ? void 0 : u.streamType;
|
|
@@ -1568,9 +1569,9 @@ async function kn(e, t) {
|
|
|
1568
1569
|
var u;
|
|
1569
1570
|
return ((u = n.streamingManager) == null ? void 0 : u.triggersAvailable) ?? !1;
|
|
1570
1571
|
},
|
|
1571
|
-
starterMessages: ((
|
|
1572
|
-
getSTTToken: () =>
|
|
1573
|
-
changeMode:
|
|
1572
|
+
starterMessages: ((N = h.knowledge) == null ? void 0 : N.starter_message) || [],
|
|
1573
|
+
getSTTToken: () => w.getSTTToken(h.id),
|
|
1574
|
+
changeMode: $,
|
|
1574
1575
|
enrichAnalytics: c.enrich,
|
|
1575
1576
|
async connect() {
|
|
1576
1577
|
await I(!0), c.track("agent-chat", {
|
|
@@ -1580,31 +1581,31 @@ async function kn(e, t) {
|
|
|
1580
1581
|
},
|
|
1581
1582
|
async reconnect() {
|
|
1582
1583
|
const u = n.streamingManager;
|
|
1583
|
-
if (
|
|
1584
|
+
if (f && (u != null && u.reconnect)) {
|
|
1584
1585
|
try {
|
|
1585
1586
|
await u.reconnect(), c.track("agent-chat", {
|
|
1586
1587
|
event: "reconnect",
|
|
1587
1588
|
mode: n.chatMode
|
|
1588
1589
|
});
|
|
1589
1590
|
} catch {
|
|
1590
|
-
await
|
|
1591
|
+
await F(), await I(!1);
|
|
1591
1592
|
}
|
|
1592
1593
|
return;
|
|
1593
1594
|
}
|
|
1594
|
-
await
|
|
1595
|
+
await F(), await I(!1), c.track("agent-chat", {
|
|
1595
1596
|
event: "reconnect",
|
|
1596
1597
|
mode: n.chatMode
|
|
1597
1598
|
});
|
|
1598
1599
|
},
|
|
1599
1600
|
async disconnect() {
|
|
1600
|
-
await
|
|
1601
|
+
await F(), c.track("agent-chat", {
|
|
1601
1602
|
event: "disconnect",
|
|
1602
1603
|
mode: n.chatMode
|
|
1603
1604
|
});
|
|
1604
1605
|
},
|
|
1605
1606
|
async publishMicrophoneStream(u) {
|
|
1606
|
-
var
|
|
1607
|
-
if (!((
|
|
1607
|
+
var S;
|
|
1608
|
+
if (!((S = n.streamingManager) != null && S.publishMicrophoneStream))
|
|
1608
1609
|
throw new Error("publishMicrophoneStream is not available for this streaming manager");
|
|
1609
1610
|
return n.streamingManager.publishMicrophoneStream(u);
|
|
1610
1611
|
},
|
|
@@ -1615,80 +1616,80 @@ async function kn(e, t) {
|
|
|
1615
1616
|
return n.streamingManager.unpublishMicrophoneStream();
|
|
1616
1617
|
},
|
|
1617
1618
|
async chat(u) {
|
|
1618
|
-
var b,
|
|
1619
|
-
const
|
|
1620
|
-
if (
|
|
1621
|
-
throw new
|
|
1619
|
+
var b, A, K, q, W;
|
|
1620
|
+
const S = () => {
|
|
1621
|
+
if (Qe(d))
|
|
1622
|
+
throw new fe(`${d} is enabled, chat is disabled`);
|
|
1622
1623
|
if (u.length >= 800)
|
|
1623
|
-
throw new
|
|
1624
|
+
throw new fe("Message cannot be more than 800 characters");
|
|
1624
1625
|
if (u.length === 0)
|
|
1625
|
-
throw new
|
|
1626
|
+
throw new fe("Message cannot be empty");
|
|
1626
1627
|
if (n.chatMode === x.Maintenance)
|
|
1627
|
-
throw new
|
|
1628
|
+
throw new fe("Chat is in maintenance mode");
|
|
1628
1629
|
if (![x.TextOnly, x.Playground].includes(n.chatMode)) {
|
|
1629
1630
|
if (!n.streamingManager)
|
|
1630
|
-
throw new
|
|
1631
|
+
throw new fe("Streaming manager is not initialized");
|
|
1631
1632
|
if (!n.chat)
|
|
1632
|
-
throw new
|
|
1633
|
+
throw new fe("Chat is not initialized");
|
|
1633
1634
|
}
|
|
1634
|
-
},
|
|
1635
|
-
var
|
|
1635
|
+
}, R = async () => {
|
|
1636
|
+
var j, B;
|
|
1636
1637
|
if (!n.chat) {
|
|
1637
|
-
const Y = await
|
|
1638
|
-
|
|
1639
|
-
|
|
1638
|
+
const Y = await Ge(
|
|
1639
|
+
h,
|
|
1640
|
+
w,
|
|
1640
1641
|
c,
|
|
1641
1642
|
n.chatMode,
|
|
1642
1643
|
t.persistentChat
|
|
1643
1644
|
);
|
|
1644
1645
|
if (!Y.chat)
|
|
1645
|
-
throw new
|
|
1646
|
-
n.chat = Y.chat, (B = (
|
|
1646
|
+
throw new at(n.chatMode, !!t.persistentChat);
|
|
1647
|
+
n.chat = Y.chat, (B = (j = t.callbacks).onNewChat) == null || B.call(j, n.chat.id);
|
|
1647
1648
|
}
|
|
1648
1649
|
return n.chat.id;
|
|
1649
|
-
}, z = async (
|
|
1650
|
+
}, z = async (j, B) => {
|
|
1650
1651
|
const Y = n.chatMode === x.Playground;
|
|
1651
|
-
return
|
|
1652
|
-
var
|
|
1653
|
-
return await ((
|
|
1652
|
+
return De(f && !Y ? async () => {
|
|
1653
|
+
var m, E;
|
|
1654
|
+
return await ((E = (m = n.streamingManager) == null ? void 0 : m.sendTextMessage) == null ? void 0 : E.call(m, u)), Promise.resolve({});
|
|
1654
1655
|
} : async () => {
|
|
1655
|
-
var
|
|
1656
|
-
return
|
|
1657
|
-
|
|
1656
|
+
var m, E;
|
|
1657
|
+
return w.chat(
|
|
1658
|
+
h.id,
|
|
1658
1659
|
B,
|
|
1659
1660
|
{
|
|
1660
1661
|
chatMode: n.chatMode,
|
|
1661
|
-
streamId: (
|
|
1662
|
-
sessionId: (
|
|
1663
|
-
messages:
|
|
1662
|
+
streamId: (m = n.streamingManager) == null ? void 0 : m.streamId,
|
|
1663
|
+
sessionId: (E = n.streamingManager) == null ? void 0 : E.sessionId,
|
|
1664
|
+
messages: j.map(({ matches: G, ...ce }) => ce)
|
|
1664
1665
|
},
|
|
1665
1666
|
{
|
|
1666
|
-
...
|
|
1667
|
+
...Ye(n.chatMode),
|
|
1667
1668
|
skipErrorHandler: !0
|
|
1668
1669
|
}
|
|
1669
1670
|
);
|
|
1670
1671
|
}, {
|
|
1671
1672
|
limit: 2,
|
|
1672
|
-
shouldRetryFn: (
|
|
1673
|
-
var
|
|
1674
|
-
const
|
|
1675
|
-
return !((
|
|
1673
|
+
shouldRetryFn: (m) => {
|
|
1674
|
+
var ce, de, we, ue;
|
|
1675
|
+
const E = (ce = m == null ? void 0 : m.message) == null ? void 0 : ce.includes("missing or invalid session_id");
|
|
1676
|
+
return !((de = m == null ? void 0 : m.message) == null ? void 0 : de.includes("Stream Error")) && !E ? ((ue = (we = t.callbacks).onError) == null || ue.call(we, m), !1) : !0;
|
|
1676
1677
|
},
|
|
1677
1678
|
onRetry: async () => {
|
|
1678
|
-
await
|
|
1679
|
+
await F(), await I(!1);
|
|
1679
1680
|
}
|
|
1680
1681
|
});
|
|
1681
1682
|
};
|
|
1682
1683
|
try {
|
|
1683
|
-
|
|
1684
|
-
id:
|
|
1684
|
+
J(), S(), n.messages.push({
|
|
1685
|
+
id: me(),
|
|
1685
1686
|
role: "user",
|
|
1686
1687
|
content: u,
|
|
1687
|
-
created_at: new Date(
|
|
1688
|
-
}), (
|
|
1689
|
-
const
|
|
1688
|
+
created_at: new Date(te.update()).toISOString()
|
|
1689
|
+
}), (A = (b = t.callbacks).onNewMessage) == null || A.call(b, [...n.messages], "user");
|
|
1690
|
+
const j = await R(), B = await z([...n.messages], j);
|
|
1690
1691
|
return n.messages.push({
|
|
1691
|
-
id:
|
|
1692
|
+
id: me(),
|
|
1692
1693
|
role: "assistant",
|
|
1693
1694
|
content: B.result || "",
|
|
1694
1695
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -1697,80 +1698,80 @@ async function kn(e, t) {
|
|
|
1697
1698
|
}), c.track("agent-message-send", {
|
|
1698
1699
|
event: "success",
|
|
1699
1700
|
messages: n.messages.length + 1
|
|
1700
|
-
}), B.result && ((
|
|
1701
|
-
latency:
|
|
1701
|
+
}), B.result && ((q = (K = t.callbacks).onNewMessage) == null || q.call(K, [...n.messages], "answer"), c.track("agent-message-received", {
|
|
1702
|
+
latency: te.get(!0),
|
|
1702
1703
|
messages: n.messages.length
|
|
1703
1704
|
})), B;
|
|
1704
|
-
} catch (
|
|
1705
|
-
throw ((
|
|
1705
|
+
} catch (j) {
|
|
1706
|
+
throw ((W = n.messages[n.messages.length - 1]) == null ? void 0 : W.role) === "assistant" && n.messages.pop(), c.track("agent-message-send", {
|
|
1706
1707
|
event: "error",
|
|
1707
1708
|
messages: n.messages.length
|
|
1708
|
-
}),
|
|
1709
|
+
}), j;
|
|
1709
1710
|
}
|
|
1710
1711
|
},
|
|
1711
|
-
rate(u,
|
|
1712
|
-
var
|
|
1713
|
-
const z = n.messages.find((
|
|
1712
|
+
rate(u, S, R) {
|
|
1713
|
+
var A, K, q, W;
|
|
1714
|
+
const z = n.messages.find((j) => j.id === u);
|
|
1714
1715
|
if (n.chat) {
|
|
1715
1716
|
if (!z)
|
|
1716
1717
|
throw new Error("Message not found");
|
|
1717
1718
|
} else throw new Error("Chat is not initialized");
|
|
1718
|
-
const b = ((
|
|
1719
|
+
const b = ((A = z.matches) == null ? void 0 : A.map((j) => [j.document_id, j.id])) ?? [];
|
|
1719
1720
|
return c.track("agent-rate", {
|
|
1720
|
-
event:
|
|
1721
|
-
thumb:
|
|
1722
|
-
knowledge_id: ((K =
|
|
1721
|
+
event: R ? "update" : "create",
|
|
1722
|
+
thumb: S === 1 ? "up" : "down",
|
|
1723
|
+
knowledge_id: ((K = h.knowledge) == null ? void 0 : K.id) ?? "",
|
|
1723
1724
|
matches: b,
|
|
1724
|
-
score:
|
|
1725
|
-
}),
|
|
1726
|
-
knowledge_id: ((
|
|
1725
|
+
score: S
|
|
1726
|
+
}), R ? w.updateRating(h.id, n.chat.id, R, {
|
|
1727
|
+
knowledge_id: ((q = h.knowledge) == null ? void 0 : q.id) ?? "",
|
|
1727
1728
|
message_id: u,
|
|
1728
1729
|
matches: b,
|
|
1729
|
-
score:
|
|
1730
|
-
}) :
|
|
1731
|
-
knowledge_id: ((
|
|
1730
|
+
score: S
|
|
1731
|
+
}) : w.createRating(h.id, n.chat.id, {
|
|
1732
|
+
knowledge_id: ((W = h.knowledge) == null ? void 0 : W.id) ?? "",
|
|
1732
1733
|
message_id: u,
|
|
1733
1734
|
matches: b,
|
|
1734
|
-
score:
|
|
1735
|
+
score: S
|
|
1735
1736
|
});
|
|
1736
1737
|
},
|
|
1737
1738
|
deleteRate(u) {
|
|
1738
1739
|
if (!n.chat)
|
|
1739
1740
|
throw new Error("Chat is not initialized");
|
|
1740
|
-
return c.track("agent-rate-delete", { type: "text" }),
|
|
1741
|
+
return c.track("agent-rate-delete", { type: "text" }), w.deleteRating(h.id, n.chat.id, u);
|
|
1741
1742
|
},
|
|
1742
1743
|
async speak(u) {
|
|
1743
|
-
var b,
|
|
1744
|
-
function
|
|
1744
|
+
var b, A, K;
|
|
1745
|
+
function S() {
|
|
1745
1746
|
if (typeof u == "string") {
|
|
1746
|
-
if (!
|
|
1747
|
+
if (!h.presenter.voice)
|
|
1747
1748
|
throw new Error("Presenter voice is not initialized");
|
|
1748
1749
|
return {
|
|
1749
1750
|
type: "text",
|
|
1750
|
-
provider:
|
|
1751
|
+
provider: h.presenter.voice,
|
|
1751
1752
|
input: u,
|
|
1752
1753
|
ssml: !1
|
|
1753
1754
|
};
|
|
1754
1755
|
}
|
|
1755
1756
|
if (u.type === "text" && !u.provider) {
|
|
1756
|
-
if (!
|
|
1757
|
+
if (!h.presenter.voice)
|
|
1757
1758
|
throw new Error("Presenter voice is not initialized");
|
|
1758
1759
|
return {
|
|
1759
1760
|
type: "text",
|
|
1760
|
-
provider:
|
|
1761
|
+
provider: h.presenter.voice,
|
|
1761
1762
|
input: u.input,
|
|
1762
1763
|
ssml: u.ssml
|
|
1763
1764
|
};
|
|
1764
1765
|
}
|
|
1765
1766
|
return u;
|
|
1766
1767
|
}
|
|
1767
|
-
const
|
|
1768
|
-
if (c.track("agent-speak",
|
|
1769
|
-
id:
|
|
1768
|
+
const R = S();
|
|
1769
|
+
if (c.track("agent-speak", R), te.update(), n.messages && R.type === "text" && (n.messages.push({
|
|
1770
|
+
id: me(),
|
|
1770
1771
|
role: "assistant",
|
|
1771
|
-
content:
|
|
1772
|
+
content: R.input,
|
|
1772
1773
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1773
|
-
}), (
|
|
1774
|
+
}), (A = (b = t.callbacks).onNewMessage) == null || A.call(b, [...n.messages], "answer")), kt(n.chatMode))
|
|
1774
1775
|
return {
|
|
1775
1776
|
duration: 0,
|
|
1776
1777
|
video_id: "",
|
|
@@ -1779,37 +1780,37 @@ async function kn(e, t) {
|
|
|
1779
1780
|
if (!n.streamingManager)
|
|
1780
1781
|
throw new Error("Please connect to the agent first");
|
|
1781
1782
|
return n.streamingManager.speak({
|
|
1782
|
-
script:
|
|
1783
|
-
metadata: { chat_id: (K = n.chat) == null ? void 0 : K.id, agent_id:
|
|
1783
|
+
script: R,
|
|
1784
|
+
metadata: { chat_id: (K = n.chat) == null ? void 0 : K.id, agent_id: h.id }
|
|
1784
1785
|
});
|
|
1785
1786
|
},
|
|
1786
|
-
interrupt:
|
|
1787
|
+
interrupt: k
|
|
1787
1788
|
};
|
|
1788
1789
|
}
|
|
1789
1790
|
export {
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1791
|
+
O as AgentActivityState,
|
|
1792
|
+
ut as AgentStatus,
|
|
1793
|
+
at as ChatCreationFailed,
|
|
1793
1794
|
x as ChatMode,
|
|
1794
|
-
|
|
1795
|
-
|
|
1795
|
+
ot as ChatModeDowngraded,
|
|
1796
|
+
X as ChatProgress,
|
|
1796
1797
|
T as ConnectionState,
|
|
1797
1798
|
ne as ConnectivityState,
|
|
1798
|
-
|
|
1799
|
+
gt as DocumentType,
|
|
1799
1800
|
mt as KnowledgeType,
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1801
|
+
dt as PlanGroup,
|
|
1802
|
+
ht as Providers,
|
|
1803
|
+
lt as RateState,
|
|
1804
|
+
L as StreamEvents,
|
|
1804
1805
|
re as StreamType,
|
|
1805
|
-
|
|
1806
|
-
|
|
1806
|
+
C as StreamingState,
|
|
1807
|
+
ft as Subject,
|
|
1807
1808
|
ke as TransportProvider,
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1809
|
+
ct as UserPlan,
|
|
1810
|
+
fe as ValidationError,
|
|
1811
|
+
Oe as VideoType,
|
|
1812
|
+
pt as VoiceAccess,
|
|
1813
|
+
st as WsError,
|
|
1814
|
+
Rn as createAgentManager,
|
|
1815
|
+
kn as mapVideoType
|
|
1815
1816
|
};
|