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