@d-id/client-sdk 1.1.0-beta.5 → 1.1.0-beta.7
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 +705 -648
- package/dist/index.umd.cjs +1 -1
- package/dist/src/api/agents.d.ts +1 -0
- package/dist/src/api/apiClient.d.ts +3 -2
- package/dist/src/services/streaming-manager/index.d.ts +1 -1
- package/dist/src/types/entities/agents/agent.d.ts +1 -0
- package/dist/src/types/entities/agents/chat.d.ts +1 -1
- package/dist/src/types/entities/agents/manager.d.ts +4 -0
- package/dist/src/types/stream/api/clip.d.ts +1 -0
- package/dist/src/types/stream/api/talk.d.ts +1 -0
- package/dist/src/types/stream/stream.d.ts +2 -0
- package/dist/src/utils/chat.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
class
|
|
1
|
+
var we = Object.defineProperty;
|
|
2
|
+
var ye = (e, t, r) => t in e ? we(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var H = (e, t, r) => (ye(e, typeof t != "symbol" ? t + "" : t, r), r);
|
|
4
|
+
class Q extends Error {
|
|
5
5
|
constructor({
|
|
6
|
-
kind:
|
|
6
|
+
kind: r,
|
|
7
7
|
description: a,
|
|
8
8
|
error: o
|
|
9
9
|
}) {
|
|
10
10
|
super(JSON.stringify({
|
|
11
|
-
kind:
|
|
11
|
+
kind: r,
|
|
12
12
|
description: a
|
|
13
13
|
}));
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
this.kind =
|
|
14
|
+
H(this, "kind");
|
|
15
|
+
H(this, "description");
|
|
16
|
+
H(this, "error");
|
|
17
|
+
this.kind = r, this.description = a, this.error = o;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
class
|
|
21
|
-
constructor(t,
|
|
20
|
+
class pe extends Q {
|
|
21
|
+
constructor(t, r) {
|
|
22
22
|
super({
|
|
23
23
|
kind: "ChatCreationFailed",
|
|
24
|
-
description: `Failed to create ${
|
|
24
|
+
description: `Failed to create ${r ? "persistent" : ""} chat, mode: ${t}`
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
class
|
|
28
|
+
class ve extends Q {
|
|
29
29
|
constructor(t) {
|
|
30
30
|
super({
|
|
31
31
|
kind: "ChatModeDowngraded",
|
|
@@ -33,17 +33,17 @@ class pe extends Y {
|
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
class
|
|
37
|
-
constructor(
|
|
36
|
+
class J extends Q {
|
|
37
|
+
constructor(r, a) {
|
|
38
38
|
super({
|
|
39
39
|
kind: "ValidationError",
|
|
40
|
-
description:
|
|
40
|
+
description: r
|
|
41
41
|
});
|
|
42
|
-
|
|
42
|
+
H(this, "key");
|
|
43
43
|
this.key = a;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
class
|
|
46
|
+
class ke extends Q {
|
|
47
47
|
constructor(t) {
|
|
48
48
|
super({
|
|
49
49
|
kind: "WSError",
|
|
@@ -51,8 +51,8 @@ class ye extends Y {
|
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
var
|
|
55
|
-
const
|
|
54
|
+
var Ce = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(Ce || {}), De = /* @__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))(De || {}), Re = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(Re || {}), _e = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(_e || {}), j = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e))(j || {}), U = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Complete = "done", e))(U || {}), Ee = /* @__PURE__ */ ((e) => (e.KnowledgeProcessing = "knowledge/processing", e.KnowledgeIndexing = "knowledge/indexing", e.KnowledgeFailed = "knowledge/error", e.KnowledgeDone = "knowledge/done", e))(Ee || {}), Se = /* @__PURE__ */ ((e) => (e.Knowledge = "knowledge", e.Document = "document", e.Record = "record", e))(Se || {}), Me = /* @__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))(Me || {}), oe = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e))(oe || {});
|
|
55
|
+
const Ie = (e) => {
|
|
56
56
|
switch (e) {
|
|
57
57
|
case "clip":
|
|
58
58
|
return "clip";
|
|
@@ -62,25 +62,25 @@ const Me = (e) => {
|
|
|
62
62
|
throw new Error(`Unknown video type: ${e}`);
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
|
-
var
|
|
66
|
-
const
|
|
65
|
+
var C = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(C || {}), W = /* @__PURE__ */ ((e) => (e.Strong = "STRONG", e.Weak = "WEAK", e.Unknown = "UNKNOWN", e))(W || {}), K = /* @__PURE__ */ ((e) => (e.Idle = "IDLE", e.Talking = "TALKING", e))(K || {});
|
|
66
|
+
const ne = {
|
|
67
67
|
"stream/started": "START",
|
|
68
68
|
"stream/done": "STOP"
|
|
69
69
|
/* Stop */
|
|
70
70
|
};
|
|
71
|
-
var
|
|
72
|
-
const
|
|
73
|
-
function
|
|
74
|
-
let
|
|
71
|
+
var Y = /* @__PURE__ */ ((e) => (e.ChatAnswer = "chat/answer", e.ChatPartial = "chat/partial", e.StreamDone = "stream/done", e.StreamStarted = "stream/started", e.StreamFailed = "stream/error", e.StreamReady = "stream/ready", e.StreamCreated = "stream/created", e.StreamVideoCreated = "stream-video/started", e.StreamVideoDone = "stream-video/done", e.StreamVideoError = "stream-video/error", e.StreamVideoRejected = "stream-video/rejected", e))(Y || {}), I = /* @__PURE__ */ ((e) => (e.New = "new", e.Fail = "fail", e.Connected = "connected", e.Connecting = "connecting", e.Closed = "closed", e.Completed = "completed", e.Disconnected = "disconnected", e))(I || {}), F = /* @__PURE__ */ ((e) => (e.Legacy = "legacy", e.Fluent = "fluent", e))(F || {}), Te = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.Microsoft = "microsoft", e.Afflorithmics = "afflorithmics", e.Elevenlabs = "elevenlabs", e))(Te || {}), je = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e))(je || {});
|
|
72
|
+
const Pe = 45 * 1e3, be = "X-Playground-Chat", q = "https://api.d-id.com", $e = "wss://notifications.d-id.com", Le = "79f81a83a67430be2bc0fd61042b8faa", ce = (e) => new Promise((t) => setTimeout(t, e)), X = () => Math.random().toString(16).slice(2), Be = (e) => [j.TextOnly, j.Playground, j.Maintenance].includes(e);
|
|
73
|
+
function Ae(e, t) {
|
|
74
|
+
let r;
|
|
75
75
|
return {
|
|
76
|
-
promise: new Promise((o,
|
|
77
|
-
|
|
76
|
+
promise: new Promise((o, i) => {
|
|
77
|
+
r = setTimeout(() => i(new Error(t)), e);
|
|
78
78
|
}),
|
|
79
|
-
clear: () => clearTimeout(
|
|
79
|
+
clear: () => clearTimeout(r)
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
|
-
async function
|
|
83
|
-
const
|
|
82
|
+
async function Z(e, t) {
|
|
83
|
+
const r = {
|
|
84
84
|
limit: (t == null ? void 0 : t.limit) ?? 3,
|
|
85
85
|
delayMs: (t == null ? void 0 : t.delayMs) ?? 0,
|
|
86
86
|
timeout: (t == null ? void 0 : t.timeout) ?? 3e4,
|
|
@@ -90,196 +90,214 @@ async function V(e, t) {
|
|
|
90
90
|
})
|
|
91
91
|
};
|
|
92
92
|
let a;
|
|
93
|
-
for (let o = 1; o <=
|
|
93
|
+
for (let o = 1; o <= r.limit; o++)
|
|
94
94
|
try {
|
|
95
|
-
if (!
|
|
95
|
+
if (!r.timeout)
|
|
96
96
|
return await e();
|
|
97
97
|
const {
|
|
98
|
-
promise:
|
|
99
|
-
clear:
|
|
100
|
-
} =
|
|
101
|
-
return await Promise.race([
|
|
102
|
-
} catch (
|
|
103
|
-
if (a =
|
|
104
|
-
throw
|
|
105
|
-
await
|
|
98
|
+
promise: i,
|
|
99
|
+
clear: n
|
|
100
|
+
} = Ae(r.timeout, r.timeoutErrorMessage), s = e().finally(n);
|
|
101
|
+
return await Promise.race([s, i]);
|
|
102
|
+
} catch (i) {
|
|
103
|
+
if (a = i, !r.shouldRetryFn(i) || o >= r.limit)
|
|
104
|
+
throw i;
|
|
105
|
+
await ce(r.delayMs), r.onRetry(i);
|
|
106
106
|
}
|
|
107
107
|
throw a;
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function de() {
|
|
110
110
|
let e = window.localStorage.getItem("did_external_key_id");
|
|
111
111
|
return e || (e = Math.random().toString(16).slice(2), window.localStorage.setItem("did_external_key_id", e)), e;
|
|
112
112
|
}
|
|
113
|
-
let
|
|
114
|
-
function
|
|
113
|
+
let ze = X();
|
|
114
|
+
function le(e) {
|
|
115
115
|
if (e.type === "bearer")
|
|
116
116
|
return `Bearer ${e.token}`;
|
|
117
117
|
if (e.type === "basic")
|
|
118
118
|
return `Basic ${btoa(`${e.username}:${e.password}`)}`;
|
|
119
119
|
if (e.type === "key")
|
|
120
|
-
return `Client-Key ${e.clientKey}.${
|
|
120
|
+
return `Client-Key ${e.clientKey}.${de()}_${ze}`;
|
|
121
121
|
throw new Error(`Unknown auth type: ${e}`);
|
|
122
122
|
}
|
|
123
|
-
const
|
|
123
|
+
const xe = (e) => Z(e, {
|
|
124
124
|
limit: 3,
|
|
125
125
|
delayMs: 1e3,
|
|
126
126
|
timeout: 0,
|
|
127
127
|
shouldRetryFn: (t) => t.status === 429
|
|
128
128
|
});
|
|
129
|
-
function
|
|
130
|
-
const a = async (o,
|
|
129
|
+
function O(e, t = q, r) {
|
|
130
|
+
const a = async (o, i) => {
|
|
131
131
|
const {
|
|
132
|
-
skipErrorHandler:
|
|
133
|
-
...
|
|
134
|
-
} =
|
|
135
|
-
...
|
|
132
|
+
skipErrorHandler: n,
|
|
133
|
+
...s
|
|
134
|
+
} = i || {}, c = await xe(() => fetch(t + (o != null && o.startsWith("/") ? o : `/${o}`), {
|
|
135
|
+
...s,
|
|
136
136
|
headers: {
|
|
137
|
-
...
|
|
138
|
-
Authorization:
|
|
137
|
+
...s.headers,
|
|
138
|
+
Authorization: le(e),
|
|
139
139
|
"Content-Type": "application/json"
|
|
140
140
|
}
|
|
141
141
|
}));
|
|
142
142
|
if (!c.ok) {
|
|
143
143
|
let l = await c.text().catch(() => `Failed to fetch with status ${c.status}`);
|
|
144
144
|
const f = new Error(l);
|
|
145
|
-
throw
|
|
145
|
+
throw r && !n && r(f, {
|
|
146
146
|
url: o,
|
|
147
|
-
options:
|
|
147
|
+
options: s,
|
|
148
148
|
headers: c.headers
|
|
149
149
|
}), f;
|
|
150
150
|
}
|
|
151
151
|
return c.json();
|
|
152
152
|
};
|
|
153
153
|
return {
|
|
154
|
-
get(o,
|
|
154
|
+
get(o, i) {
|
|
155
155
|
return a(o, {
|
|
156
|
-
...
|
|
156
|
+
...i,
|
|
157
157
|
method: "GET"
|
|
158
158
|
});
|
|
159
159
|
},
|
|
160
|
-
post(o,
|
|
160
|
+
post(o, i, n) {
|
|
161
161
|
return a(o, {
|
|
162
|
-
...
|
|
163
|
-
body: JSON.stringify(
|
|
162
|
+
...n,
|
|
163
|
+
body: JSON.stringify(i),
|
|
164
164
|
method: "POST"
|
|
165
165
|
});
|
|
166
166
|
},
|
|
167
|
-
|
|
167
|
+
put(o, i, n) {
|
|
168
168
|
return a(o, {
|
|
169
|
-
...
|
|
170
|
-
body: JSON.stringify(
|
|
169
|
+
...n,
|
|
170
|
+
body: JSON.stringify(i),
|
|
171
|
+
method: "PUT"
|
|
172
|
+
});
|
|
173
|
+
},
|
|
174
|
+
delete(o, i, n) {
|
|
175
|
+
return a(o, {
|
|
176
|
+
...n,
|
|
177
|
+
body: JSON.stringify(i),
|
|
171
178
|
method: "DELETE"
|
|
172
179
|
});
|
|
173
180
|
},
|
|
174
|
-
patch(o,
|
|
181
|
+
patch(o, i, n) {
|
|
175
182
|
return a(o, {
|
|
176
|
-
...
|
|
177
|
-
body: JSON.stringify(
|
|
183
|
+
...n,
|
|
184
|
+
body: JSON.stringify(i),
|
|
178
185
|
method: "PATCH"
|
|
179
186
|
});
|
|
180
187
|
}
|
|
181
188
|
};
|
|
182
189
|
}
|
|
183
|
-
function
|
|
184
|
-
const a =
|
|
190
|
+
function ue(e, t = q, r) {
|
|
191
|
+
const a = O(e, `${t}/agents`, r);
|
|
185
192
|
return {
|
|
186
|
-
|
|
187
|
-
return
|
|
193
|
+
joinChat(o, i, n, s) {
|
|
194
|
+
return console.info("joinChat", {
|
|
195
|
+
userId: o,
|
|
196
|
+
externalId: i,
|
|
197
|
+
chatId: n,
|
|
198
|
+
options: s
|
|
199
|
+
}), a.put(`/chats/${n}`, {
|
|
200
|
+
user_id: o,
|
|
201
|
+
external_id: i
|
|
202
|
+
}, s);
|
|
203
|
+
},
|
|
204
|
+
create(o, i) {
|
|
205
|
+
return a.post("/", o, i);
|
|
188
206
|
},
|
|
189
|
-
getAgents(o,
|
|
190
|
-
return a.get(`/${o ? `?tag=${o}` : ""}`,
|
|
207
|
+
getAgents(o, i) {
|
|
208
|
+
return a.get(`/${o ? `?tag=${o}` : ""}`, i).then((n) => n ?? []);
|
|
191
209
|
},
|
|
192
|
-
getById(o,
|
|
193
|
-
return a.get(`/${o}`,
|
|
210
|
+
getById(o, i) {
|
|
211
|
+
return a.get(`/${o}`, i);
|
|
194
212
|
},
|
|
195
|
-
delete(o,
|
|
196
|
-
return a.delete(`/${o}`, void 0,
|
|
213
|
+
delete(o, i) {
|
|
214
|
+
return a.delete(`/${o}`, void 0, i);
|
|
197
215
|
},
|
|
198
|
-
update(o,
|
|
199
|
-
return a.patch(`/${o}`,
|
|
216
|
+
update(o, i, n) {
|
|
217
|
+
return a.patch(`/${o}`, i, n);
|
|
200
218
|
},
|
|
201
|
-
newChat(o,
|
|
202
|
-
return a.post(`/${o}/chat`,
|
|
219
|
+
newChat(o, i, n) {
|
|
220
|
+
return a.post(`/${o}/chat`, i, n);
|
|
203
221
|
},
|
|
204
|
-
chat(o,
|
|
205
|
-
return a.post(`/${o}/chat/${
|
|
222
|
+
chat(o, i, n, s) {
|
|
223
|
+
return a.post(`/${o}/chat/${i}`, n, s);
|
|
206
224
|
},
|
|
207
|
-
createRating(o,
|
|
208
|
-
return a.post(`/${o}/chat/${
|
|
225
|
+
createRating(o, i, n, s) {
|
|
226
|
+
return a.post(`/${o}/chat/${i}/ratings`, n, s);
|
|
209
227
|
},
|
|
210
|
-
updateRating(o,
|
|
211
|
-
return a.patch(`/${o}/chat/${
|
|
228
|
+
updateRating(o, i, n, s, c) {
|
|
229
|
+
return a.patch(`/${o}/chat/${i}/ratings/${n}`, s, c);
|
|
212
230
|
},
|
|
213
|
-
deleteRating(o,
|
|
214
|
-
return a.delete(`/${o}/chat/${
|
|
231
|
+
deleteRating(o, i, n, s) {
|
|
232
|
+
return a.delete(`/${o}/chat/${i}/ratings/${n}`, s);
|
|
215
233
|
},
|
|
216
|
-
getSTTToken(o,
|
|
217
|
-
return a.get(`/${o}/stt-token`,
|
|
234
|
+
getSTTToken(o, i) {
|
|
235
|
+
return a.get(`/${o}/stt-token`, i);
|
|
218
236
|
}
|
|
219
237
|
};
|
|
220
238
|
}
|
|
221
|
-
const
|
|
222
|
-
function
|
|
223
|
-
var o,
|
|
224
|
-
const t = () => /Mobi|Android/i.test(navigator.userAgent) ? "Mobile" : "Desktop",
|
|
239
|
+
const fe = (e) => e.type === "clip" && e.presenter_id.startsWith("v2_") ? "clip_v2" : e.type;
|
|
240
|
+
function Ne(e) {
|
|
241
|
+
var o, i, n, s;
|
|
242
|
+
const t = () => /Mobi|Android/i.test(navigator.userAgent) ? "Mobile" : "Desktop", r = () => {
|
|
225
243
|
const c = navigator.platform;
|
|
226
244
|
return c.toLowerCase().includes("win") ? "Windows" : c.toLowerCase().includes("mac") ? "Mac OS X" : c.toLowerCase().includes("linux") ? "Linux" : "Unknown";
|
|
227
245
|
}, a = e.presenter;
|
|
228
246
|
return {
|
|
229
|
-
$os: `${
|
|
247
|
+
$os: `${r()}`,
|
|
230
248
|
isMobile: `${t() == "Mobile"}`,
|
|
231
249
|
browser: navigator.userAgent,
|
|
232
250
|
origin: window.location.origin,
|
|
233
|
-
agentType:
|
|
251
|
+
agentType: fe(a),
|
|
234
252
|
agentVoice: {
|
|
235
|
-
voiceId: (
|
|
236
|
-
provider: (
|
|
253
|
+
voiceId: (i = (o = e.presenter) == null ? void 0 : o.voice) == null ? void 0 : i.voice_id,
|
|
254
|
+
provider: (s = (n = e.presenter) == null ? void 0 : n.voice) == null ? void 0 : s.type
|
|
237
255
|
}
|
|
238
256
|
};
|
|
239
257
|
}
|
|
240
|
-
const
|
|
241
|
-
function
|
|
258
|
+
const Fe = (e) => e.reduce((t, r) => t + r, 0), Je = (e) => Fe(e) / e.length;
|
|
259
|
+
function Ue(e, t, r) {
|
|
242
260
|
var c, l, f;
|
|
243
261
|
const {
|
|
244
262
|
event: a,
|
|
245
263
|
...o
|
|
246
264
|
} = e, {
|
|
247
|
-
template:
|
|
265
|
+
template: i
|
|
248
266
|
} = (t == null ? void 0 : t.llm) || {}, {
|
|
249
|
-
language:
|
|
267
|
+
language: n
|
|
250
268
|
} = ((c = t == null ? void 0 : t.presenter) == null ? void 0 : c.voice) || {};
|
|
251
269
|
return {
|
|
252
270
|
...o,
|
|
253
271
|
llm: {
|
|
254
272
|
...o.llm,
|
|
255
|
-
template:
|
|
273
|
+
template: i
|
|
256
274
|
},
|
|
257
275
|
script: {
|
|
258
276
|
...o.script,
|
|
259
277
|
provider: {
|
|
260
278
|
...(l = o == null ? void 0 : o.script) == null ? void 0 : l.provider,
|
|
261
|
-
language:
|
|
279
|
+
language: n
|
|
262
280
|
}
|
|
263
281
|
},
|
|
264
282
|
stitch: (t == null ? void 0 : t.presenter.type) === "talk" ? (f = t == null ? void 0 : t.presenter) == null ? void 0 : f.stitch : void 0,
|
|
265
|
-
...
|
|
283
|
+
...r
|
|
266
284
|
};
|
|
267
285
|
}
|
|
268
|
-
let
|
|
269
|
-
const
|
|
270
|
-
function
|
|
271
|
-
var
|
|
272
|
-
const t = window != null && window.hasOwnProperty("DID_AGENTS_API") ? "agents-ui" : "agents-sdk",
|
|
286
|
+
let V = {};
|
|
287
|
+
const We = "https://api-js.mixpanel.com/track/?verbose=1&ip=1";
|
|
288
|
+
function He(e) {
|
|
289
|
+
var i, n, s, c, l, f;
|
|
290
|
+
const t = window != null && window.hasOwnProperty("DID_AGENTS_API") ? "agents-ui" : "agents-sdk", r = e.agent.presenter, a = (i = e.agent.llm) == null ? void 0 : i.prompt_customization, o = {
|
|
273
291
|
token: e.token || "testKey",
|
|
274
|
-
distinct_id: e.distinctId ||
|
|
292
|
+
distinct_id: e.distinctId || de(),
|
|
275
293
|
agentId: e.agent.id,
|
|
276
|
-
agentType:
|
|
294
|
+
agentType: fe(r),
|
|
277
295
|
owner_id: e.agent.owner_id ?? "",
|
|
278
|
-
promptVersion: (
|
|
296
|
+
promptVersion: (n = e.agent.llm) == null ? void 0 : n.prompt_version,
|
|
279
297
|
behavior: {
|
|
280
298
|
role: a == null ? void 0 : a.role,
|
|
281
299
|
personality: a == null ? void 0 : a.personality,
|
|
282
|
-
instructions: (
|
|
300
|
+
instructions: (s = e.agent.llm) == null ? void 0 : s.instructions
|
|
283
301
|
},
|
|
284
302
|
temperature: (c = e.agent.llm) == null ? void 0 : c.temperature,
|
|
285
303
|
knowledgeSource: a == null ? void 0 : a.knowledge_source,
|
|
@@ -296,8 +314,8 @@ function Je(e) {
|
|
|
296
314
|
const D = {};
|
|
297
315
|
if (m && typeof m != "object")
|
|
298
316
|
throw new Error("properties must be a flat json object");
|
|
299
|
-
for (let
|
|
300
|
-
(typeof m[
|
|
317
|
+
for (let y in m)
|
|
318
|
+
(typeof m[y] == "string" || typeof m[y] == "number") && (D[y] = m[y]);
|
|
301
319
|
this.additionalProperties = {
|
|
302
320
|
...this.additionalProperties,
|
|
303
321
|
...D
|
|
@@ -307,8 +325,8 @@ function Je(e) {
|
|
|
307
325
|
if (!this.isEnabled)
|
|
308
326
|
return Promise.resolve();
|
|
309
327
|
const {
|
|
310
|
-
audioPath:
|
|
311
|
-
...
|
|
328
|
+
audioPath: y,
|
|
329
|
+
...w
|
|
312
330
|
} = D || {}, R = {
|
|
313
331
|
method: "POST",
|
|
314
332
|
headers: {
|
|
@@ -319,7 +337,7 @@ function Je(e) {
|
|
|
319
337
|
event: m,
|
|
320
338
|
properties: {
|
|
321
339
|
...this.additionalProperties,
|
|
322
|
-
...
|
|
340
|
+
...w,
|
|
323
341
|
...o,
|
|
324
342
|
source: t,
|
|
325
343
|
time: Date.now(),
|
|
@@ -333,32 +351,32 @@ function Je(e) {
|
|
|
333
351
|
})
|
|
334
352
|
};
|
|
335
353
|
try {
|
|
336
|
-
return await fetch(
|
|
337
|
-
} catch (
|
|
338
|
-
return console.error(
|
|
354
|
+
return await fetch(We, R).then((L) => L.json());
|
|
355
|
+
} catch (L) {
|
|
356
|
+
return console.error(L);
|
|
339
357
|
}
|
|
340
358
|
},
|
|
341
|
-
linkTrack(m, D,
|
|
342
|
-
|
|
359
|
+
linkTrack(m, D, y, w) {
|
|
360
|
+
V[m] || (V[m] = {
|
|
343
361
|
events: {},
|
|
344
362
|
resolvedDependencies: []
|
|
345
|
-
}),
|
|
346
|
-
const R =
|
|
347
|
-
if (R.events[
|
|
363
|
+
}), w.includes(y) || w.push(y);
|
|
364
|
+
const R = V[m];
|
|
365
|
+
if (R.events[y] = {
|
|
348
366
|
props: D
|
|
349
|
-
}, R.resolvedDependencies.push(
|
|
350
|
-
const
|
|
351
|
-
...
|
|
352
|
-
...R.events[
|
|
353
|
-
} :
|
|
354
|
-
this.track(m,
|
|
355
|
-
delete R.events[
|
|
367
|
+
}, R.resolvedDependencies.push(y), w.every((E) => R.resolvedDependencies.includes(E))) {
|
|
368
|
+
const E = w.reduce((P, d) => R.events[d] ? {
|
|
369
|
+
...P,
|
|
370
|
+
...R.events[d].props
|
|
371
|
+
} : P, {});
|
|
372
|
+
this.track(m, E), R.resolvedDependencies = R.resolvedDependencies.filter((P) => !w.includes(P)), w.forEach((P) => {
|
|
373
|
+
delete R.events[P];
|
|
356
374
|
});
|
|
357
375
|
}
|
|
358
376
|
}
|
|
359
377
|
};
|
|
360
378
|
}
|
|
361
|
-
function
|
|
379
|
+
function Ke() {
|
|
362
380
|
let e = 0;
|
|
363
381
|
return {
|
|
364
382
|
reset: () => e = 0,
|
|
@@ -366,228 +384,233 @@ function We() {
|
|
|
366
384
|
get: (t = !1) => t ? Date.now() - e : e
|
|
367
385
|
};
|
|
368
386
|
}
|
|
369
|
-
const N =
|
|
370
|
-
function
|
|
371
|
-
return e ===
|
|
387
|
+
const N = Ke();
|
|
388
|
+
function me(e) {
|
|
389
|
+
return e === j.Playground ? {
|
|
372
390
|
headers: {
|
|
373
|
-
[
|
|
391
|
+
[be]: "true"
|
|
374
392
|
}
|
|
375
393
|
} : {};
|
|
376
394
|
}
|
|
377
|
-
async function
|
|
395
|
+
async function ge(e, t, r, a, o = !1, i) {
|
|
378
396
|
try {
|
|
379
|
-
return !
|
|
397
|
+
return !i && a !== j.DirectPlayback && (i = await t.newChat(e.id, {
|
|
380
398
|
persist: o
|
|
381
|
-
},
|
|
399
|
+
}, me(a)), r.track("agent-chat", {
|
|
382
400
|
event: "created",
|
|
383
|
-
chat_id:
|
|
401
|
+
chat_id: i.id,
|
|
384
402
|
agent_id: e.id,
|
|
385
403
|
mode: a
|
|
386
404
|
})), {
|
|
387
|
-
chat:
|
|
388
|
-
chatMode: (
|
|
405
|
+
chat: i,
|
|
406
|
+
chatMode: (i == null ? void 0 : i.chat_mode) ?? a
|
|
389
407
|
};
|
|
390
|
-
} catch (
|
|
408
|
+
} catch (n) {
|
|
391
409
|
try {
|
|
392
|
-
const
|
|
393
|
-
if ((
|
|
410
|
+
const s = JSON.parse(n.message);
|
|
411
|
+
if ((s == null ? void 0 : s.kind) === "InsufficientCreditsError")
|
|
394
412
|
throw new Error("InsufficientCreditsError");
|
|
395
|
-
} catch (
|
|
396
|
-
console.error("Error parsing the error message:",
|
|
413
|
+
} catch (s) {
|
|
414
|
+
console.error("Error parsing the error message:", s);
|
|
397
415
|
}
|
|
398
416
|
throw new Error("Cannot create new chat");
|
|
399
417
|
}
|
|
400
418
|
}
|
|
401
|
-
function
|
|
419
|
+
function qe(e) {
|
|
402
420
|
return e && e.length > 0 ? e : [];
|
|
403
421
|
}
|
|
404
|
-
function
|
|
405
|
-
return new Promise((t,
|
|
422
|
+
function Xe(e) {
|
|
423
|
+
return new Promise((t, r) => {
|
|
406
424
|
const {
|
|
407
425
|
callbacks: a,
|
|
408
426
|
host: o,
|
|
409
|
-
auth:
|
|
427
|
+
auth: i
|
|
410
428
|
} = e, {
|
|
411
|
-
onMessage:
|
|
412
|
-
onOpen:
|
|
429
|
+
onMessage: n = null,
|
|
430
|
+
onOpen: s = null,
|
|
413
431
|
onClose: c = null,
|
|
414
432
|
onError: l = null
|
|
415
|
-
} = a || {}, f = new WebSocket(`${o}?authorization=${
|
|
416
|
-
f.onmessage =
|
|
417
|
-
console.error(m), l == null || l("Websocket failed to connect", m),
|
|
433
|
+
} = a || {}, f = new WebSocket(`${o}?authorization=${le(i)}`);
|
|
434
|
+
f.onmessage = n, f.onclose = c, f.onerror = (m) => {
|
|
435
|
+
console.error(m), l == null || l("Websocket failed to connect", m), r(m);
|
|
418
436
|
}, f.onopen = (m) => {
|
|
419
|
-
|
|
437
|
+
s == null || s(m), t(f);
|
|
420
438
|
};
|
|
421
439
|
});
|
|
422
440
|
}
|
|
423
|
-
async function
|
|
441
|
+
async function Ye(e) {
|
|
424
442
|
const {
|
|
425
443
|
retries: t = 1
|
|
426
444
|
} = e;
|
|
427
|
-
let
|
|
428
|
-
for (let a = 0; (
|
|
445
|
+
let r = null;
|
|
446
|
+
for (let a = 0; (r == null ? void 0 : r.readyState) !== WebSocket.OPEN; a++)
|
|
429
447
|
try {
|
|
430
|
-
|
|
448
|
+
r = await Xe(e);
|
|
431
449
|
} catch (o) {
|
|
432
450
|
if (a === t)
|
|
433
451
|
throw o;
|
|
434
|
-
await
|
|
452
|
+
await ce(a * 500);
|
|
435
453
|
}
|
|
436
|
-
return
|
|
454
|
+
return r;
|
|
437
455
|
}
|
|
438
|
-
async function
|
|
439
|
-
const a =
|
|
456
|
+
async function Qe(e, t, r) {
|
|
457
|
+
const a = r != null && r.onMessage ? [r.onMessage] : [], o = await Ye({
|
|
440
458
|
auth: e,
|
|
441
459
|
host: t,
|
|
442
460
|
callbacks: {
|
|
443
|
-
onError: (
|
|
444
|
-
var
|
|
445
|
-
return (
|
|
461
|
+
onError: (i) => {
|
|
462
|
+
var n;
|
|
463
|
+
return (n = r.onError) == null ? void 0 : n.call(r, new ke(i));
|
|
446
464
|
},
|
|
447
|
-
onMessage(
|
|
448
|
-
|
|
449
|
-
|
|
465
|
+
onMessage(i) {
|
|
466
|
+
console.log("onMessage", i);
|
|
467
|
+
const n = JSON.parse(i.data);
|
|
468
|
+
a.forEach((s) => s(n.event, n));
|
|
450
469
|
}
|
|
451
470
|
}
|
|
452
471
|
});
|
|
453
472
|
return {
|
|
454
473
|
socket: o,
|
|
455
474
|
disconnect: () => o.close(),
|
|
456
|
-
subscribeToEvents: (
|
|
475
|
+
subscribeToEvents: (i) => a.push(i)
|
|
457
476
|
};
|
|
458
477
|
}
|
|
459
|
-
function
|
|
478
|
+
function Ve(e) {
|
|
460
479
|
if (e.answer !== void 0)
|
|
461
480
|
return e.answer;
|
|
462
|
-
let t = 0,
|
|
481
|
+
let t = 0, r = "";
|
|
463
482
|
for (; t in e; )
|
|
464
|
-
|
|
465
|
-
return
|
|
483
|
+
r += e[t++];
|
|
484
|
+
return r;
|
|
466
485
|
}
|
|
467
|
-
function
|
|
468
|
-
const
|
|
469
|
-
if (!(e ===
|
|
486
|
+
function Ze(e, t, r, a, o) {
|
|
487
|
+
const i = a.messages[a.messages.length - 1];
|
|
488
|
+
if (!(e === U.Partial || e === U.Answer) || (i == null ? void 0 : i.role) !== "assistant")
|
|
470
489
|
return;
|
|
471
490
|
const {
|
|
472
|
-
content:
|
|
473
|
-
sequence:
|
|
491
|
+
content: n,
|
|
492
|
+
sequence: s
|
|
474
493
|
} = t;
|
|
475
|
-
e ===
|
|
476
|
-
const c =
|
|
477
|
-
(
|
|
494
|
+
e === U.Partial ? r[s] = n : r.answer = n;
|
|
495
|
+
const c = Ve(r);
|
|
496
|
+
(i.content !== c || e === U.Answer) && (i.content = c, o == null || o([...a.messages], e));
|
|
478
497
|
}
|
|
479
|
-
function
|
|
480
|
-
let
|
|
498
|
+
function Ge(e, t, r, a, o) {
|
|
499
|
+
let i = {};
|
|
481
500
|
return {
|
|
482
|
-
clearQueue: () =>
|
|
483
|
-
onMessage: (
|
|
501
|
+
clearQueue: () => i = {},
|
|
502
|
+
onMessage: (n, s) => {
|
|
484
503
|
var c, l;
|
|
485
|
-
if ("content" in
|
|
486
|
-
|
|
504
|
+
if ("content" in s)
|
|
505
|
+
Ze(n, s, i, t, r.callbacks.onNewMessage), n === U.Answer && e.track("agent-message-received", {
|
|
487
506
|
messages: t.messages.length,
|
|
488
507
|
mode: t.chatMode
|
|
489
508
|
});
|
|
490
509
|
else {
|
|
491
|
-
const f =
|
|
510
|
+
const f = Y, m = [f.StreamVideoDone, f.StreamVideoError, f.StreamVideoRejected], D = [f.StreamFailed, f.StreamVideoError, f.StreamVideoRejected], y = Ue(s, a, {
|
|
492
511
|
mode: t.chatMode
|
|
493
512
|
});
|
|
494
|
-
if (
|
|
495
|
-
e.linkTrack("agent-video",
|
|
496
|
-
else if (m.includes(
|
|
497
|
-
const
|
|
498
|
-
D.includes(
|
|
499
|
-
...
|
|
500
|
-
event:
|
|
513
|
+
if (n = n, n === f.StreamVideoCreated)
|
|
514
|
+
e.linkTrack("agent-video", y, f.StreamVideoCreated, ["start"]);
|
|
515
|
+
else if (m.includes(n)) {
|
|
516
|
+
const w = n.split("/")[1];
|
|
517
|
+
D.includes(n) ? e.track("agent-video", {
|
|
518
|
+
...y,
|
|
519
|
+
event: w
|
|
501
520
|
}) : e.linkTrack("agent-video", {
|
|
502
|
-
...
|
|
503
|
-
event:
|
|
504
|
-
},
|
|
521
|
+
...y,
|
|
522
|
+
event: w
|
|
523
|
+
}, n, ["done"]);
|
|
505
524
|
}
|
|
506
|
-
D.includes(
|
|
507
|
-
data:
|
|
508
|
-
})),
|
|
525
|
+
D.includes(n) && ((l = (c = r.callbacks).onError) == null || l.call(c, new Error(`Stream failed with event ${n}`), {
|
|
526
|
+
data: s
|
|
527
|
+
})), s.event === f.StreamDone && o();
|
|
509
528
|
}
|
|
510
529
|
}
|
|
511
530
|
};
|
|
512
531
|
}
|
|
513
|
-
function
|
|
514
|
-
const o =
|
|
532
|
+
function Oe(e, t, r, a) {
|
|
533
|
+
const o = O(e, `${t}/agents/${r}`, a);
|
|
515
534
|
return {
|
|
516
|
-
createStream(
|
|
517
|
-
return
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
535
|
+
createStream(i) {
|
|
536
|
+
return console.log("createClipApi", {
|
|
537
|
+
options: i
|
|
538
|
+
}), o.post("/streams", {
|
|
539
|
+
output_resolution: i.output_resolution,
|
|
540
|
+
compatibility_mode: i.compatibility_mode,
|
|
541
|
+
stream_warmup: i.stream_warmup,
|
|
542
|
+
session_timeout: i.session_timeout,
|
|
543
|
+
fluent: i.fluent,
|
|
544
|
+
conn_id: i.conn_id
|
|
523
545
|
});
|
|
524
546
|
},
|
|
525
|
-
startConnection(
|
|
526
|
-
return o.post(`/streams/${
|
|
527
|
-
session_id:
|
|
528
|
-
answer:
|
|
547
|
+
startConnection(i, n, s) {
|
|
548
|
+
return o.post(`/streams/${i}/sdp`, {
|
|
549
|
+
session_id: s,
|
|
550
|
+
answer: n
|
|
529
551
|
});
|
|
530
552
|
},
|
|
531
|
-
addIceCandidate(
|
|
532
|
-
return o.post(`/streams/${
|
|
533
|
-
session_id:
|
|
534
|
-
...
|
|
553
|
+
addIceCandidate(i, n, s) {
|
|
554
|
+
return o.post(`/streams/${i}/ice`, {
|
|
555
|
+
session_id: s,
|
|
556
|
+
...n
|
|
535
557
|
});
|
|
536
558
|
},
|
|
537
|
-
sendStreamRequest(
|
|
538
|
-
return o.post(`/streams/${
|
|
539
|
-
session_id:
|
|
540
|
-
...
|
|
559
|
+
sendStreamRequest(i, n, s) {
|
|
560
|
+
return o.post(`/streams/${i}`, {
|
|
561
|
+
session_id: n,
|
|
562
|
+
...s
|
|
541
563
|
});
|
|
542
564
|
},
|
|
543
|
-
close(
|
|
544
|
-
return o.delete(`/streams/${
|
|
545
|
-
session_id:
|
|
565
|
+
close(i, n) {
|
|
566
|
+
return o.delete(`/streams/${i}`, {
|
|
567
|
+
session_id: n
|
|
546
568
|
});
|
|
547
569
|
}
|
|
548
570
|
};
|
|
549
571
|
}
|
|
550
|
-
function
|
|
551
|
-
const o =
|
|
572
|
+
function et(e, t, r, a) {
|
|
573
|
+
const o = O(e, `${t}/agents/${r}`, a);
|
|
552
574
|
return {
|
|
553
|
-
createStream(
|
|
575
|
+
createStream(i, n) {
|
|
554
576
|
return o.post("/streams", {
|
|
555
|
-
driver_url:
|
|
556
|
-
face:
|
|
557
|
-
config:
|
|
558
|
-
output_resolution:
|
|
559
|
-
compatibility_mode:
|
|
560
|
-
stream_warmup:
|
|
561
|
-
session_timeout:
|
|
562
|
-
fluent:
|
|
563
|
-
|
|
577
|
+
driver_url: i.driver_url,
|
|
578
|
+
face: i.face,
|
|
579
|
+
config: i.config,
|
|
580
|
+
output_resolution: i.output_resolution,
|
|
581
|
+
compatibility_mode: i.compatibility_mode,
|
|
582
|
+
stream_warmup: i.stream_warmup,
|
|
583
|
+
session_timeout: i.session_timeout,
|
|
584
|
+
fluent: i.fluent,
|
|
585
|
+
conn_id: i.conn_id
|
|
586
|
+
}, n);
|
|
564
587
|
},
|
|
565
|
-
startConnection(
|
|
566
|
-
return o.post(`/streams/${
|
|
567
|
-
session_id:
|
|
568
|
-
answer:
|
|
588
|
+
startConnection(i, n, s, c) {
|
|
589
|
+
return o.post(`/streams/${i}/sdp`, {
|
|
590
|
+
session_id: s,
|
|
591
|
+
answer: n
|
|
569
592
|
}, c);
|
|
570
593
|
},
|
|
571
|
-
addIceCandidate(
|
|
572
|
-
return o.post(`/streams/${
|
|
573
|
-
session_id:
|
|
574
|
-
...
|
|
594
|
+
addIceCandidate(i, n, s, c) {
|
|
595
|
+
return o.post(`/streams/${i}/ice`, {
|
|
596
|
+
session_id: s,
|
|
597
|
+
...n
|
|
575
598
|
}, c);
|
|
576
599
|
},
|
|
577
|
-
sendStreamRequest(
|
|
578
|
-
return o.post(`/streams/${
|
|
579
|
-
session_id:
|
|
580
|
-
...
|
|
600
|
+
sendStreamRequest(i, n, s, c) {
|
|
601
|
+
return o.post(`/streams/${i}`, {
|
|
602
|
+
session_id: n,
|
|
603
|
+
...s
|
|
581
604
|
}, c);
|
|
582
605
|
},
|
|
583
|
-
close(
|
|
584
|
-
return o.delete(`/streams/${
|
|
585
|
-
session_id:
|
|
586
|
-
},
|
|
606
|
+
close(i, n, s) {
|
|
607
|
+
return o.delete(`/streams/${i}`, {
|
|
608
|
+
session_id: n
|
|
609
|
+
}, s);
|
|
587
610
|
}
|
|
588
611
|
};
|
|
589
612
|
}
|
|
590
|
-
function
|
|
613
|
+
function tt(e, t, r) {
|
|
591
614
|
const a = (t.timestamp - e.timestamp) / 1e3;
|
|
592
615
|
return {
|
|
593
616
|
duration: a,
|
|
@@ -604,13 +627,13 @@ function Ge(e, t, n) {
|
|
|
604
627
|
framesPerSecond: t.framesPerSecond,
|
|
605
628
|
freezeCount: t.freezeCount - e.freezeCount,
|
|
606
629
|
freezeDuration: t.freezeDuration - e.freezeDuration,
|
|
607
|
-
lowFpsCount:
|
|
630
|
+
lowFpsCount: r
|
|
608
631
|
};
|
|
609
632
|
}
|
|
610
|
-
function
|
|
633
|
+
function nt(e) {
|
|
611
634
|
return e.filter((t) => t.freezeCount > 0 || t.framesPerSecond < 21 || t.framesDropped > 0 || t.packetsLost > 0).map((t) => {
|
|
612
635
|
const {
|
|
613
|
-
timestamp:
|
|
636
|
+
timestamp: r,
|
|
614
637
|
...a
|
|
615
638
|
} = t, o = [];
|
|
616
639
|
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"), {
|
|
@@ -619,109 +642,109 @@ function Oe(e) {
|
|
|
619
642
|
};
|
|
620
643
|
});
|
|
621
644
|
}
|
|
622
|
-
function
|
|
645
|
+
function rt(e) {
|
|
623
646
|
let t = "";
|
|
624
|
-
for (const
|
|
625
|
-
if (
|
|
647
|
+
for (const r of e.values())
|
|
648
|
+
if (r && r.type === "codec" && r.mimeType.startsWith("video") && (t = r.mimeType.split("/")[1]), r && r.type === "inbound-rtp" && r.kind === "video")
|
|
626
649
|
return {
|
|
627
650
|
codec: t,
|
|
628
|
-
timestamp:
|
|
629
|
-
bytesReceived:
|
|
630
|
-
packetsReceived:
|
|
631
|
-
packetsLost:
|
|
632
|
-
framesDropped:
|
|
633
|
-
framesDecoded:
|
|
634
|
-
jitter:
|
|
635
|
-
jitterBufferDelay:
|
|
636
|
-
jitterBufferEmittedCount:
|
|
637
|
-
avgJitterDelayInInterval:
|
|
638
|
-
frameWidth:
|
|
639
|
-
frameHeight:
|
|
640
|
-
framesPerSecond:
|
|
641
|
-
freezeCount:
|
|
642
|
-
freezeDuration:
|
|
651
|
+
timestamp: r.timestamp,
|
|
652
|
+
bytesReceived: r.bytesReceived,
|
|
653
|
+
packetsReceived: r.packetsReceived,
|
|
654
|
+
packetsLost: r.packetsLost,
|
|
655
|
+
framesDropped: r.framesDropped,
|
|
656
|
+
framesDecoded: r.framesDecoded,
|
|
657
|
+
jitter: r.jitter,
|
|
658
|
+
jitterBufferDelay: r.jitterBufferDelay,
|
|
659
|
+
jitterBufferEmittedCount: r.jitterBufferEmittedCount,
|
|
660
|
+
avgJitterDelayInInterval: r.jitterBufferDelay / r.jitterBufferEmittedCount,
|
|
661
|
+
frameWidth: r.frameWidth,
|
|
662
|
+
frameHeight: r.frameHeight,
|
|
663
|
+
framesPerSecond: r.framesPerSecond,
|
|
664
|
+
freezeCount: r.freezeCount,
|
|
665
|
+
freezeDuration: r.totalFreezesDuration
|
|
643
666
|
};
|
|
644
667
|
return {};
|
|
645
668
|
}
|
|
646
|
-
function
|
|
647
|
-
const a = e.map((
|
|
648
|
-
timestamp:
|
|
669
|
+
function at(e, t, r) {
|
|
670
|
+
const a = e.map((s, c) => c === 0 ? r ? {
|
|
671
|
+
timestamp: s.timestamp,
|
|
649
672
|
duration: 0,
|
|
650
|
-
bytesReceived:
|
|
651
|
-
bitrate: (
|
|
652
|
-
packetsReceived:
|
|
653
|
-
packetsLost:
|
|
654
|
-
framesDropped:
|
|
655
|
-
framesDecoded:
|
|
656
|
-
jitter:
|
|
657
|
-
jitterBufferDelay:
|
|
658
|
-
jitterBufferEmittedCount:
|
|
659
|
-
avgJitterDelayInInterval: (
|
|
660
|
-
framesPerSecond:
|
|
661
|
-
freezeCount:
|
|
662
|
-
freezeDuration:
|
|
673
|
+
bytesReceived: s.bytesReceived - r.bytesReceived,
|
|
674
|
+
bitrate: (s.bytesReceived - r.bytesReceived) * 8 / (t / 1e3),
|
|
675
|
+
packetsReceived: s.packetsReceived - r.packetsReceived,
|
|
676
|
+
packetsLost: s.packetsLost - r.packetsLost,
|
|
677
|
+
framesDropped: s.framesDropped - r.framesDropped,
|
|
678
|
+
framesDecoded: s.framesDecoded - r.framesDecoded,
|
|
679
|
+
jitter: s.jitter,
|
|
680
|
+
jitterBufferDelay: s.jitterBufferDelay - r.jitterBufferDelay,
|
|
681
|
+
jitterBufferEmittedCount: s.jitterBufferEmittedCount - r.jitterBufferEmittedCount,
|
|
682
|
+
avgJitterDelayInInterval: (s.jitterBufferDelay - r.jitterBufferDelay) / (s.jitterBufferEmittedCount - r.jitterBufferEmittedCount),
|
|
683
|
+
framesPerSecond: s.framesPerSecond,
|
|
684
|
+
freezeCount: s.freezeCount - r.freezeCount,
|
|
685
|
+
freezeDuration: s.freezeDuration - r.freezeDuration
|
|
663
686
|
} : {
|
|
664
|
-
timestamp:
|
|
687
|
+
timestamp: s.timestamp,
|
|
665
688
|
duration: 0,
|
|
666
|
-
bytesReceived:
|
|
667
|
-
bitrate:
|
|
668
|
-
packetsReceived:
|
|
669
|
-
packetsLost:
|
|
670
|
-
framesDropped:
|
|
671
|
-
framesDecoded:
|
|
672
|
-
jitter:
|
|
673
|
-
jitterBufferDelay:
|
|
674
|
-
jitterBufferEmittedCount:
|
|
675
|
-
avgJitterDelayInInterval:
|
|
676
|
-
framesPerSecond:
|
|
677
|
-
freezeCount:
|
|
678
|
-
freezeDuration:
|
|
689
|
+
bytesReceived: s.bytesReceived,
|
|
690
|
+
bitrate: s.bytesReceived * 8 / (t / 1e3),
|
|
691
|
+
packetsReceived: s.packetsReceived,
|
|
692
|
+
packetsLost: s.packetsLost,
|
|
693
|
+
framesDropped: s.framesDropped,
|
|
694
|
+
framesDecoded: s.framesDecoded,
|
|
695
|
+
jitter: s.jitter,
|
|
696
|
+
jitterBufferDelay: s.jitterBufferDelay,
|
|
697
|
+
jitterBufferEmittedCount: s.jitterBufferEmittedCount,
|
|
698
|
+
avgJitterDelayInInterval: s.jitterBufferDelay / s.jitterBufferEmittedCount,
|
|
699
|
+
framesPerSecond: s.framesPerSecond,
|
|
700
|
+
freezeCount: s.freezeCount,
|
|
701
|
+
freezeDuration: s.freezeDuration
|
|
679
702
|
} : {
|
|
680
|
-
timestamp:
|
|
703
|
+
timestamp: s.timestamp,
|
|
681
704
|
duration: t * c / 1e3,
|
|
682
|
-
bytesReceived:
|
|
683
|
-
bitrate: (
|
|
684
|
-
packetsReceived:
|
|
685
|
-
packetsLost:
|
|
686
|
-
framesDropped:
|
|
687
|
-
framesDecoded:
|
|
688
|
-
jitter:
|
|
689
|
-
jitterBufferDelay:
|
|
690
|
-
jitterBufferEmittedCount:
|
|
691
|
-
avgJitterDelayInInterval: (
|
|
692
|
-
framesPerSecond:
|
|
693
|
-
freezeCount:
|
|
694
|
-
freezeDuration:
|
|
695
|
-
}), o =
|
|
705
|
+
bytesReceived: s.bytesReceived - e[c - 1].bytesReceived,
|
|
706
|
+
bitrate: (s.bytesReceived - e[c - 1].bytesReceived) * 8 / (t / 1e3),
|
|
707
|
+
packetsReceived: s.packetsReceived - e[c - 1].packetsReceived,
|
|
708
|
+
packetsLost: s.packetsLost - e[c - 1].packetsLost,
|
|
709
|
+
framesDropped: s.framesDropped - e[c - 1].framesDropped,
|
|
710
|
+
framesDecoded: s.framesDecoded - e[c - 1].framesDecoded,
|
|
711
|
+
jitter: s.jitter,
|
|
712
|
+
jitterBufferDelay: s.jitterBufferDelay - e[c - 1].jitterBufferDelay,
|
|
713
|
+
jitterBufferEmittedCount: s.jitterBufferEmittedCount - e[c - 1].jitterBufferEmittedCount,
|
|
714
|
+
avgJitterDelayInInterval: (s.jitterBufferDelay - e[c - 1].jitterBufferDelay) / (s.jitterBufferEmittedCount - e[c - 1].jitterBufferEmittedCount),
|
|
715
|
+
framesPerSecond: s.framesPerSecond,
|
|
716
|
+
freezeCount: s.freezeCount - e[c - 1].freezeCount,
|
|
717
|
+
freezeDuration: s.freezeDuration - e[c - 1].freezeDuration
|
|
718
|
+
}), o = nt(a), i = o.reduce((s, c) => s + (c.causes.includes("low fps") ? 1 : 0), 0), n = a.map((s) => s.avgJitterDelayInInterval);
|
|
696
719
|
return {
|
|
697
720
|
webRTCStats: {
|
|
698
721
|
anomalies: o,
|
|
699
|
-
aggregateReport:
|
|
700
|
-
minJitterDelayInInterval: Math.min(...
|
|
701
|
-
maxJitterDelayInInterval: Math.max(...
|
|
702
|
-
avgJitterDelayInInterval:
|
|
722
|
+
aggregateReport: tt(e[0], e[e.length - 1], i),
|
|
723
|
+
minJitterDelayInInterval: Math.min(...n),
|
|
724
|
+
maxJitterDelayInInterval: Math.max(...n),
|
|
725
|
+
avgJitterDelayInInterval: Je(n)
|
|
703
726
|
},
|
|
704
727
|
codec: e[0].codec,
|
|
705
728
|
resolution: `${e[0].frameWidth}x${e[0].frameHeight}`
|
|
706
729
|
};
|
|
707
730
|
}
|
|
708
|
-
const
|
|
709
|
-
function
|
|
710
|
-
let e = 0, t,
|
|
731
|
+
const G = 100, it = Math.max(Math.ceil(400 / G), 1), st = 0.25, ot = 0.28;
|
|
732
|
+
function ct() {
|
|
733
|
+
let e = 0, t, r, a = 0;
|
|
711
734
|
return (o) => {
|
|
712
|
-
for (const
|
|
713
|
-
if (
|
|
714
|
-
const
|
|
715
|
-
if (
|
|
716
|
-
const f =
|
|
735
|
+
for (const i of o.values())
|
|
736
|
+
if (i && i.type === "inbound-rtp" && i.kind === "video") {
|
|
737
|
+
const n = i.jitterBufferDelay, s = i.jitterBufferEmittedCount;
|
|
738
|
+
if (r && s > r) {
|
|
739
|
+
const f = n - t, m = s - r;
|
|
717
740
|
a = f / m;
|
|
718
741
|
}
|
|
719
|
-
t =
|
|
720
|
-
const c =
|
|
742
|
+
t = n, r = s;
|
|
743
|
+
const c = i.framesDecoded, l = c - e > 0;
|
|
721
744
|
return e = c, {
|
|
722
745
|
isReceiving: l,
|
|
723
746
|
avgJitterDelayInInterval: a,
|
|
724
|
-
freezeCount:
|
|
747
|
+
freezeCount: i.freezeCount
|
|
725
748
|
};
|
|
726
749
|
}
|
|
727
750
|
return {
|
|
@@ -730,276 +753,297 @@ function it() {
|
|
|
730
753
|
};
|
|
731
754
|
};
|
|
732
755
|
}
|
|
733
|
-
function
|
|
734
|
-
let
|
|
735
|
-
const
|
|
756
|
+
function dt(e, t, r, a, o, i = !1) {
|
|
757
|
+
let n = [], s, c = 0, l = !1, f = W.Unknown, m = W.Unknown, D = 0, y = 0;
|
|
758
|
+
const w = ct();
|
|
736
759
|
return setInterval(async () => {
|
|
737
760
|
const R = await e.getStats(), {
|
|
738
|
-
isReceiving:
|
|
739
|
-
avgJitterDelayInInterval:
|
|
740
|
-
freezeCount:
|
|
741
|
-
} =
|
|
742
|
-
if (
|
|
743
|
-
c = 0, D =
|
|
744
|
-
else if (l && (c++, c >=
|
|
745
|
-
const
|
|
746
|
-
a == null || a(
|
|
761
|
+
isReceiving: L,
|
|
762
|
+
avgJitterDelayInInterval: E,
|
|
763
|
+
freezeCount: P
|
|
764
|
+
} = w(R), d = rt(R);
|
|
765
|
+
if (L)
|
|
766
|
+
c = 0, D = P - y, m = E < st ? W.Strong : E > ot && D > 1 ? W.Weak : f, m !== f && (o == null || o(m), f = m, y += D, D = 0), l || (a == null || a(C.Start), s = n[n.length - 1], n = [], l = !0), n.push(d);
|
|
767
|
+
else if (l && (c++, c >= it)) {
|
|
768
|
+
const h = at(n, G, s);
|
|
769
|
+
a == null || a(C.Stop, h), t() || r(), l = !1;
|
|
747
770
|
}
|
|
748
|
-
},
|
|
771
|
+
}, G);
|
|
749
772
|
}
|
|
750
|
-
let
|
|
751
|
-
const
|
|
773
|
+
let he = !1;
|
|
774
|
+
const x = (e, t) => he && console.log(e, t), lt = (window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection).bind(window);
|
|
752
775
|
function re(e) {
|
|
753
776
|
switch (e) {
|
|
754
777
|
case "connected":
|
|
755
|
-
return
|
|
778
|
+
return I.Connected;
|
|
756
779
|
case "checking":
|
|
757
|
-
return
|
|
780
|
+
return I.Connecting;
|
|
758
781
|
case "failed":
|
|
759
|
-
return
|
|
782
|
+
return I.Fail;
|
|
760
783
|
case "new":
|
|
761
|
-
return
|
|
784
|
+
return I.New;
|
|
762
785
|
case "closed":
|
|
763
|
-
return
|
|
786
|
+
return I.Closed;
|
|
764
787
|
case "disconnected":
|
|
765
|
-
return
|
|
788
|
+
return I.Disconnected;
|
|
766
789
|
case "completed":
|
|
767
|
-
return
|
|
790
|
+
return I.Completed;
|
|
768
791
|
default:
|
|
769
|
-
return
|
|
792
|
+
return I.New;
|
|
770
793
|
}
|
|
771
794
|
}
|
|
772
|
-
function
|
|
795
|
+
function ut({
|
|
773
796
|
statsSignal: e,
|
|
774
797
|
dataChannelSignal: t,
|
|
775
|
-
onVideoStateChange:
|
|
798
|
+
onVideoStateChange: r,
|
|
776
799
|
report: a
|
|
777
800
|
}) {
|
|
778
|
-
e ===
|
|
801
|
+
e === C.Start && t === C.Start ? r == null || r(C.Start) : e === C.Stop && t === C.Stop && (r == null || r(C.Stop, a));
|
|
779
802
|
}
|
|
780
|
-
function
|
|
803
|
+
function ft({
|
|
781
804
|
statsSignal: e,
|
|
782
805
|
dataChannelSignal: t,
|
|
783
|
-
onVideoStateChange:
|
|
806
|
+
onVideoStateChange: r,
|
|
784
807
|
onAgentActivityStateChange: a,
|
|
785
808
|
report: o
|
|
786
809
|
}) {
|
|
787
|
-
e ===
|
|
810
|
+
e === C.Start ? r == null || r(C.Start) : e === C.Stop && (r == null || r(C.Stop, o)), t === C.Start ? a == null || a(K.Talking) : t === C.Stop && (a == null || a(K.Idle));
|
|
788
811
|
}
|
|
789
|
-
function
|
|
812
|
+
function ae({
|
|
790
813
|
statsSignal: e,
|
|
791
814
|
dataChannelSignal: t,
|
|
792
|
-
onVideoStateChange:
|
|
815
|
+
onVideoStateChange: r,
|
|
793
816
|
onAgentActivityStateChange: a,
|
|
794
817
|
streamType: o,
|
|
795
|
-
report:
|
|
818
|
+
report: i
|
|
796
819
|
}) {
|
|
797
|
-
o === F.Legacy ?
|
|
820
|
+
o === F.Legacy ? ut({
|
|
798
821
|
statsSignal: e,
|
|
799
822
|
dataChannelSignal: t,
|
|
800
|
-
onVideoStateChange:
|
|
801
|
-
report:
|
|
802
|
-
}) : o === F.Fluent &&
|
|
823
|
+
onVideoStateChange: r,
|
|
824
|
+
report: i
|
|
825
|
+
}) : o === F.Fluent && ft({
|
|
803
826
|
statsSignal: e,
|
|
804
827
|
dataChannelSignal: t,
|
|
805
|
-
onVideoStateChange:
|
|
828
|
+
onVideoStateChange: r,
|
|
806
829
|
onAgentActivityStateChange: a,
|
|
807
|
-
report:
|
|
830
|
+
report: i
|
|
808
831
|
});
|
|
809
832
|
}
|
|
810
|
-
async function
|
|
811
|
-
debug:
|
|
833
|
+
async function mt(e, t, {
|
|
834
|
+
debug: r = !1,
|
|
812
835
|
callbacks: a,
|
|
813
836
|
auth: o,
|
|
814
|
-
baseURL:
|
|
837
|
+
baseURL: i = q,
|
|
838
|
+
analytics: n
|
|
815
839
|
}) {
|
|
816
|
-
|
|
817
|
-
let
|
|
840
|
+
he = r;
|
|
841
|
+
let s = !1, c = !1, l = C.Stop, f = C.Stop, m = W.Unknown;
|
|
842
|
+
console.log("OFEK TEST");
|
|
818
843
|
const {
|
|
819
|
-
startConnection:
|
|
820
|
-
sendStreamRequest:
|
|
844
|
+
startConnection: D,
|
|
845
|
+
sendStreamRequest: y,
|
|
821
846
|
close: w,
|
|
822
|
-
createStream:
|
|
823
|
-
addIceCandidate:
|
|
824
|
-
} = t.videoType ===
|
|
825
|
-
id:
|
|
847
|
+
createStream: R,
|
|
848
|
+
addIceCandidate: L
|
|
849
|
+
} = t.videoType === oe.Clip ? Oe(o, i, e, a.onError) : et(o, i, e, a.onError), {
|
|
850
|
+
id: E,
|
|
826
851
|
offer: P,
|
|
827
852
|
ice_servers: d,
|
|
828
|
-
session_id:
|
|
829
|
-
fluent:
|
|
830
|
-
} = await
|
|
853
|
+
session_id: h,
|
|
854
|
+
fluent: k
|
|
855
|
+
} = await R(t), g = new lt({
|
|
831
856
|
iceServers: d
|
|
832
|
-
}),
|
|
833
|
-
if (!
|
|
857
|
+
}), S = g.createDataChannel("JanusDataChannel");
|
|
858
|
+
if (!h)
|
|
834
859
|
throw new Error("Could not create session_id");
|
|
835
|
-
const
|
|
860
|
+
const p = k ? F.Fluent : F.Legacy;
|
|
861
|
+
n.enrich({
|
|
862
|
+
"stream-type": p
|
|
863
|
+
});
|
|
864
|
+
const M = t.stream_warmup && !k, b = () => s, B = () => {
|
|
836
865
|
var u;
|
|
837
|
-
|
|
838
|
-
},
|
|
839
|
-
statsSignal:
|
|
840
|
-
dataChannelSignal:
|
|
866
|
+
s = !0, c && ((u = a.onConnectionStateChange) == null || u.call(a, I.Connected));
|
|
867
|
+
}, _ = dt(g, b, B, (u, v) => ae({
|
|
868
|
+
statsSignal: f = u,
|
|
869
|
+
dataChannelSignal: p === F.Legacy ? l : void 0,
|
|
841
870
|
onVideoStateChange: a.onVideoStateChange,
|
|
842
871
|
onAgentActivityStateChange: a.onAgentActivityStateChange,
|
|
843
|
-
report:
|
|
844
|
-
streamType:
|
|
872
|
+
report: v,
|
|
873
|
+
streamType: p
|
|
845
874
|
}), (u) => {
|
|
846
|
-
var
|
|
847
|
-
return (
|
|
848
|
-
},
|
|
849
|
-
|
|
850
|
-
var
|
|
851
|
-
|
|
875
|
+
var v;
|
|
876
|
+
return (v = a.onConnectivityStateChange) == null ? void 0 : v.call(a, m);
|
|
877
|
+
}, M);
|
|
878
|
+
g.onicecandidate = (u) => {
|
|
879
|
+
var v;
|
|
880
|
+
x("peerConnection.onicecandidate", u);
|
|
852
881
|
try {
|
|
853
|
-
u.candidate && u.candidate.sdpMid && u.candidate.sdpMLineIndex !== null ?
|
|
882
|
+
u.candidate && u.candidate.sdpMid && u.candidate.sdpMLineIndex !== null ? L(E, {
|
|
854
883
|
candidate: u.candidate.candidate,
|
|
855
884
|
sdpMid: u.candidate.sdpMid,
|
|
856
885
|
sdpMLineIndex: u.candidate.sdpMLineIndex
|
|
857
|
-
},
|
|
886
|
+
}, h) : L(E, {
|
|
858
887
|
candidate: null
|
|
859
|
-
},
|
|
860
|
-
} catch (
|
|
861
|
-
(
|
|
862
|
-
streamId:
|
|
888
|
+
}, h);
|
|
889
|
+
} catch ($) {
|
|
890
|
+
(v = a.onError) == null || v.call(a, $, {
|
|
891
|
+
streamId: E
|
|
863
892
|
});
|
|
864
893
|
}
|
|
865
|
-
},
|
|
866
|
-
|
|
867
|
-
},
|
|
868
|
-
u.data in
|
|
869
|
-
statsSignal:
|
|
870
|
-
dataChannelSignal:
|
|
894
|
+
}, S.onopen = () => {
|
|
895
|
+
c = !0, (!M || s) && B();
|
|
896
|
+
}, S.onmessage = (u) => {
|
|
897
|
+
u.data in ne && (l = ne[u.data], ae({
|
|
898
|
+
statsSignal: p === F.Legacy ? f : void 0,
|
|
899
|
+
dataChannelSignal: l,
|
|
871
900
|
onVideoStateChange: a.onVideoStateChange,
|
|
872
901
|
onAgentActivityStateChange: a.onAgentActivityStateChange,
|
|
873
|
-
streamType:
|
|
902
|
+
streamType: p
|
|
874
903
|
}));
|
|
875
|
-
},
|
|
876
|
-
var
|
|
877
|
-
|
|
878
|
-
const u = re(
|
|
879
|
-
u !==
|
|
880
|
-
},
|
|
881
|
-
var
|
|
882
|
-
|
|
883
|
-
}, await
|
|
884
|
-
const
|
|
885
|
-
return
|
|
904
|
+
}, g.oniceconnectionstatechange = () => {
|
|
905
|
+
var v;
|
|
906
|
+
x("peerConnection.oniceconnectionstatechange => " + g.iceConnectionState);
|
|
907
|
+
const u = re(g.iceConnectionState);
|
|
908
|
+
u !== I.Connected && ((v = a.onConnectionStateChange) == null || v.call(a, u));
|
|
909
|
+
}, g.ontrack = (u) => {
|
|
910
|
+
var v;
|
|
911
|
+
x("peerConnection.ontrack", u), (v = a.onSrcObjectReady) == null || v.call(a, u.streams[0]);
|
|
912
|
+
}, await g.setRemoteDescription(P), x("set remote description OK");
|
|
913
|
+
const T = await g.createAnswer();
|
|
914
|
+
return x("create answer OK"), await g.setLocalDescription(T), x("set local description OK"), await D(E, T, h), x("start connection OK"), {
|
|
886
915
|
/**
|
|
887
916
|
* Method to send request to server to get clip or talk depend on you payload
|
|
888
917
|
* @param payload
|
|
889
918
|
*/
|
|
890
919
|
speak(u) {
|
|
891
|
-
return
|
|
920
|
+
return y(E, h, u);
|
|
892
921
|
},
|
|
893
922
|
/**
|
|
894
923
|
* Method to close RTC connection
|
|
895
924
|
*/
|
|
896
925
|
async disconnect() {
|
|
897
|
-
var u,
|
|
898
|
-
if (
|
|
899
|
-
const
|
|
900
|
-
if (
|
|
901
|
-
if (
|
|
902
|
-
(u = a.onVideoStateChange) == null || u.call(a,
|
|
926
|
+
var u, v, $;
|
|
927
|
+
if (E) {
|
|
928
|
+
const A = re(g.iceConnectionState);
|
|
929
|
+
if (g) {
|
|
930
|
+
if (A === I.New) {
|
|
931
|
+
(u = a.onVideoStateChange) == null || u.call(a, C.Stop), clearInterval(_);
|
|
903
932
|
return;
|
|
904
933
|
}
|
|
905
|
-
|
|
934
|
+
g.close(), g.oniceconnectionstatechange = null, g.onnegotiationneeded = null, g.onicecandidate = null, g.ontrack = null;
|
|
906
935
|
}
|
|
907
936
|
try {
|
|
908
|
-
|
|
937
|
+
A === I.Connected && await w(E, h).catch((z) => {
|
|
909
938
|
});
|
|
910
|
-
} catch (
|
|
911
|
-
|
|
939
|
+
} catch (z) {
|
|
940
|
+
x("Error on close stream connection", z);
|
|
912
941
|
}
|
|
913
|
-
(
|
|
942
|
+
(v = a.onVideoStateChange) == null || v.call(a, C.Stop), ($ = a.onAgentActivityStateChange) == null || $.call(a, K.Idle), clearInterval(_);
|
|
914
943
|
}
|
|
915
944
|
},
|
|
916
945
|
/**
|
|
917
946
|
* Session identifier information, should be returned in the body of all streaming requests
|
|
918
947
|
*/
|
|
919
|
-
sessionId:
|
|
948
|
+
sessionId: h,
|
|
920
949
|
/**
|
|
921
950
|
* Id of current RTC stream
|
|
922
951
|
*/
|
|
923
|
-
streamId:
|
|
924
|
-
streamType:
|
|
952
|
+
streamId: E,
|
|
953
|
+
streamType: p
|
|
925
954
|
};
|
|
926
955
|
}
|
|
927
|
-
function
|
|
956
|
+
function gt(e, t) {
|
|
928
957
|
const {
|
|
929
|
-
streamOptions:
|
|
930
|
-
} = t ?? {};
|
|
958
|
+
streamOptions: r
|
|
959
|
+
} = t ?? {}, o = new URLSearchParams(window.location.search).get("conn_id") || void 0;
|
|
931
960
|
return {
|
|
932
|
-
videoType:
|
|
933
|
-
output_resolution:
|
|
934
|
-
session_timeout:
|
|
935
|
-
stream_warmup:
|
|
936
|
-
compatibility_mode:
|
|
937
|
-
fluent:
|
|
961
|
+
videoType: Ie(e.presenter.type),
|
|
962
|
+
output_resolution: r == null ? void 0 : r.outputResolution,
|
|
963
|
+
session_timeout: r == null ? void 0 : r.sessionTimeout,
|
|
964
|
+
stream_warmup: r == null ? void 0 : r.streamWarmup,
|
|
965
|
+
compatibility_mode: r == null ? void 0 : r.compatibilityMode,
|
|
966
|
+
fluent: r == null ? void 0 : r.fluent,
|
|
967
|
+
conn_id: o
|
|
938
968
|
};
|
|
939
969
|
}
|
|
940
|
-
function
|
|
941
|
-
N.get() > 0 && (e ===
|
|
970
|
+
function ie(e, t, r, a, o) {
|
|
971
|
+
N.get() > 0 && (e === C.Start ? a.linkTrack("agent-video", {
|
|
942
972
|
event: "start",
|
|
943
973
|
latency: N.get(!0),
|
|
944
974
|
"stream-type": o
|
|
945
|
-
}, "start", [
|
|
975
|
+
}, "start", [Y.StreamVideoCreated]) : e === C.Stop && a.linkTrack("agent-video", {
|
|
946
976
|
event: "stop",
|
|
947
977
|
is_greenscreen: t.presenter.type === "clip" && t.presenter.is_greenscreen,
|
|
948
978
|
background: t.presenter.type === "clip" && t.presenter.background,
|
|
949
979
|
"stream-type": o,
|
|
950
|
-
...
|
|
951
|
-
}, "done", [
|
|
980
|
+
...r
|
|
981
|
+
}, "done", [Y.StreamVideoDone]));
|
|
952
982
|
}
|
|
953
|
-
function
|
|
983
|
+
function se(e, t, r) {
|
|
954
984
|
return N.reset(), new Promise(async (a, o) => {
|
|
955
985
|
try {
|
|
956
|
-
const
|
|
986
|
+
const i = await mt(e.id, gt(e, t), {
|
|
957
987
|
...t,
|
|
958
|
-
analytics:
|
|
988
|
+
analytics: r,
|
|
959
989
|
callbacks: {
|
|
960
990
|
...t.callbacks,
|
|
961
|
-
onConnectionStateChange: (
|
|
962
|
-
var
|
|
963
|
-
(c = (
|
|
991
|
+
onConnectionStateChange: (n) => {
|
|
992
|
+
var s, c;
|
|
993
|
+
(c = (s = t.callbacks).onConnectionStateChange) == null || c.call(s, n), n === I.Connected && a(i);
|
|
964
994
|
},
|
|
965
|
-
onVideoStateChange: (
|
|
995
|
+
onVideoStateChange: (n, s) => {
|
|
966
996
|
var c, l;
|
|
967
|
-
(l = (c = t.callbacks).onVideoStateChange) == null || l.call(c,
|
|
997
|
+
(l = (c = t.callbacks).onVideoStateChange) == null || l.call(c, n), ie(n, e, s, r, i.streamType);
|
|
968
998
|
},
|
|
969
|
-
onAgentActivityStateChange: (
|
|
970
|
-
var
|
|
971
|
-
(c = (
|
|
999
|
+
onAgentActivityStateChange: (n) => {
|
|
1000
|
+
var s, c;
|
|
1001
|
+
(c = (s = t.callbacks).onAgentActivityStateChange) == null || c.call(s, n), ie(n === K.Talking ? C.Start : C.Stop, e, void 0, r, i.streamType);
|
|
972
1002
|
}
|
|
973
1003
|
}
|
|
974
1004
|
});
|
|
975
|
-
} catch (
|
|
976
|
-
o(
|
|
1005
|
+
} catch (i) {
|
|
1006
|
+
o(i);
|
|
977
1007
|
}
|
|
978
1008
|
});
|
|
979
1009
|
}
|
|
980
|
-
async function
|
|
981
|
-
var
|
|
982
|
-
const
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
1010
|
+
async function ht(e, t, r, a, o) {
|
|
1011
|
+
var l, f, m, D;
|
|
1012
|
+
const i = new URLSearchParams(window.location.search), n = i.get("conn_id") || void 0, s = i.get("external_chat_id") || void 0, c = i.get("external_owner_id") || void 0;
|
|
1013
|
+
if (s && c && n) {
|
|
1014
|
+
console.log("join chat", {
|
|
1015
|
+
connId: n,
|
|
1016
|
+
externalChatId: s,
|
|
1017
|
+
userId: c
|
|
1018
|
+
});
|
|
1019
|
+
const y = await r.joinChat(c, n, s), w = await se(e, t, a);
|
|
1020
|
+
return {
|
|
1021
|
+
chat: y,
|
|
1022
|
+
streamingManager: w
|
|
989
1023
|
};
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
1024
|
+
} else {
|
|
1025
|
+
const {
|
|
1026
|
+
chat: y,
|
|
1027
|
+
chatMode: w
|
|
1028
|
+
} = await ge(e, r, a, t.mode, t.persistentChat, o);
|
|
1029
|
+
if (w && w !== t.mode && (t.mode = w, (f = (l = t.callbacks).onModeChange) == null || f.call(l, w), w === j.TextOnly))
|
|
1030
|
+
return (D = (m = t.callbacks).onError) == null || D.call(m, new ve(w)), {
|
|
1031
|
+
chat: y
|
|
1032
|
+
};
|
|
1033
|
+
const R = await se(e, t, a);
|
|
1034
|
+
return {
|
|
1035
|
+
chat: y,
|
|
1036
|
+
streamingManager: R
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
995
1039
|
}
|
|
996
|
-
async function
|
|
997
|
-
var
|
|
998
|
-
let
|
|
999
|
-
const a = t.mixpanelKey ||
|
|
1040
|
+
async function yt(e, t) {
|
|
1041
|
+
var L, E, P;
|
|
1042
|
+
let r = !0;
|
|
1043
|
+
const a = t.mixpanelKey || Le, o = t.wsURL || $e, i = t.baseURL || q, n = {
|
|
1000
1044
|
messages: [],
|
|
1001
|
-
chatMode: t.mode ||
|
|
1002
|
-
},
|
|
1045
|
+
chatMode: t.mode || j.Functional
|
|
1046
|
+
}, s = ue(t.auth, i, t.callbacks.onError), c = await s.getById(e), l = He({
|
|
1003
1047
|
token: a,
|
|
1004
1048
|
agent: c,
|
|
1005
1049
|
isEnabled: t.enableAnalitics,
|
|
@@ -1007,210 +1051,218 @@ async function ht(e, t) {
|
|
|
1007
1051
|
}), {
|
|
1008
1052
|
onMessage: f,
|
|
1009
1053
|
clearQueue: m
|
|
1010
|
-
} =
|
|
1054
|
+
} = Ge(l, n, t, c, () => {
|
|
1011
1055
|
var d;
|
|
1012
|
-
return (d =
|
|
1056
|
+
return (d = n.socketManager) == null ? void 0 : d.disconnect();
|
|
1013
1057
|
});
|
|
1014
|
-
|
|
1058
|
+
n.messages = qe(t.initialMessages), (E = (L = t.callbacks).onNewMessage) == null || E.call(L, [...n.messages], "answer");
|
|
1059
|
+
function D() {
|
|
1060
|
+
var S, p, M;
|
|
1061
|
+
const d = (S = n.streamingManager) == null ? void 0 : S.streamId, h = (p = n.chat) == null ? void 0 : p.owner_id, k = (M = n.chat) == null ? void 0 : M.id, g = window.location + `?conn_id=${d}&external_chat_id=${k}&external_owner_id=${h}`;
|
|
1062
|
+
return console.info(g), g;
|
|
1063
|
+
}
|
|
1064
|
+
l.track("agent-sdk", {
|
|
1015
1065
|
event: "loaded",
|
|
1016
|
-
...
|
|
1066
|
+
...Ne(c)
|
|
1017
1067
|
});
|
|
1018
|
-
async function
|
|
1019
|
-
var
|
|
1020
|
-
(
|
|
1021
|
-
const
|
|
1068
|
+
async function y(d) {
|
|
1069
|
+
var M, b, B, _, T, u, v;
|
|
1070
|
+
(b = (M = t.callbacks).onConnectionStateChange) == null || b.call(M, I.Connecting), N.reset(), d && !r && (delete n.chat, (_ = (B = t.callbacks).onNewMessage) == null || _.call(B, [...n.messages], "answer"));
|
|
1071
|
+
const h = t.mode === j.DirectPlayback ? Promise.resolve(void 0) : Qe(t.auth, o, {
|
|
1022
1072
|
onMessage: f,
|
|
1023
1073
|
onError: t.callbacks.onError
|
|
1024
|
-
}),
|
|
1074
|
+
}), k = Z(() => ht(c, t, s, l, n.chat), {
|
|
1025
1075
|
limit: 3,
|
|
1026
|
-
timeout:
|
|
1076
|
+
timeout: Pe,
|
|
1027
1077
|
timeoutErrorMessage: "Timeout initializing the stream",
|
|
1028
1078
|
// Retry on all errors except for connection errors and rate limit errors, these are already handled in client level.
|
|
1029
|
-
shouldRetryFn: (
|
|
1079
|
+
shouldRetryFn: ($) => ($ == null ? void 0 : $.message) !== "Could not connect" && $.status !== 429,
|
|
1030
1080
|
delayMs: 1e3
|
|
1031
|
-
}).catch((
|
|
1032
|
-
var
|
|
1033
|
-
throw
|
|
1034
|
-
}), [
|
|
1035
|
-
streamingManager:
|
|
1036
|
-
chat:
|
|
1037
|
-
}] = await Promise.all([
|
|
1038
|
-
|
|
1081
|
+
}).catch(($) => {
|
|
1082
|
+
var A, z;
|
|
1083
|
+
throw R(j.Maintenance), (z = (A = t.callbacks).onConnectionStateChange) == null || z.call(A, I.Fail), $;
|
|
1084
|
+
}), [g, {
|
|
1085
|
+
streamingManager: S,
|
|
1086
|
+
chat: p
|
|
1087
|
+
}] = await Promise.all([h, k]);
|
|
1088
|
+
p && p.id !== ((T = n.chat) == null ? void 0 : T.id) && ((v = (u = t.callbacks).onNewChat) == null || v.call(u, p.id)), n.streamingManager = S, n.socketManager = g, n.chat = p, r = !1, R((p == null ? void 0 : p.chat_mode) ?? t.mode ?? j.Functional);
|
|
1039
1089
|
}
|
|
1040
1090
|
async function w() {
|
|
1041
|
-
var d,
|
|
1042
|
-
(d =
|
|
1091
|
+
var d, h, k, g;
|
|
1092
|
+
(d = n.socketManager) == null || d.disconnect(), await ((h = n.streamingManager) == null ? void 0 : h.disconnect()), delete n.streamingManager, delete n.socketManager, (g = (k = t.callbacks).onConnectionStateChange) == null || g.call(k, I.Disconnected);
|
|
1043
1093
|
}
|
|
1044
|
-
async function
|
|
1045
|
-
var
|
|
1046
|
-
d !==
|
|
1094
|
+
async function R(d) {
|
|
1095
|
+
var h, k;
|
|
1096
|
+
d !== n.chatMode && (l.track("agent-mode-change", {
|
|
1047
1097
|
mode: d
|
|
1048
|
-
}),
|
|
1098
|
+
}), n.chatMode = d, n.chatMode !== j.Functional && await w(), (k = (h = t.callbacks).onModeChange) == null || k.call(h, d));
|
|
1049
1099
|
}
|
|
1050
1100
|
return {
|
|
1051
1101
|
agent: c,
|
|
1102
|
+
getInviteLink: D,
|
|
1052
1103
|
getStreamType: () => {
|
|
1053
1104
|
var d;
|
|
1054
|
-
return (d =
|
|
1105
|
+
return (d = n.streamingManager) == null ? void 0 : d.streamType;
|
|
1055
1106
|
},
|
|
1056
1107
|
starterMessages: ((P = c.knowledge) == null ? void 0 : P.starter_message) || [],
|
|
1057
|
-
getSTTToken: () =>
|
|
1058
|
-
changeMode:
|
|
1108
|
+
getSTTToken: () => s.getSTTToken(c.id),
|
|
1109
|
+
changeMode: R,
|
|
1059
1110
|
enrichAnalytics: l.enrich,
|
|
1060
1111
|
async connect() {
|
|
1061
1112
|
var d;
|
|
1062
|
-
await
|
|
1113
|
+
await y(!0), l.track("agent-chat", {
|
|
1063
1114
|
event: "connect",
|
|
1064
|
-
chatId: (d =
|
|
1115
|
+
chatId: (d = n.chat) == null ? void 0 : d.id,
|
|
1065
1116
|
agentId: c.id,
|
|
1066
|
-
mode:
|
|
1117
|
+
mode: n.chatMode
|
|
1067
1118
|
});
|
|
1068
1119
|
},
|
|
1069
1120
|
async reconnect() {
|
|
1070
1121
|
var d;
|
|
1071
|
-
await w(), await
|
|
1122
|
+
await w(), await y(!1), l.track("agent-chat", {
|
|
1072
1123
|
event: "reconnect",
|
|
1073
|
-
chatId: (d =
|
|
1124
|
+
chatId: (d = n.chat) == null ? void 0 : d.id,
|
|
1074
1125
|
agentId: c.id,
|
|
1075
|
-
mode:
|
|
1126
|
+
mode: n.chatMode
|
|
1076
1127
|
});
|
|
1077
1128
|
},
|
|
1078
1129
|
async disconnect() {
|
|
1079
1130
|
var d;
|
|
1080
1131
|
await w(), l.track("agent-chat", {
|
|
1081
1132
|
event: "disconnect",
|
|
1082
|
-
chatId: (d =
|
|
1133
|
+
chatId: (d = n.chat) == null ? void 0 : d.id,
|
|
1083
1134
|
agentId: c.id,
|
|
1084
|
-
mode:
|
|
1135
|
+
mode: n.chatMode
|
|
1085
1136
|
});
|
|
1086
1137
|
},
|
|
1087
1138
|
async chat(d) {
|
|
1088
|
-
var
|
|
1089
|
-
const
|
|
1090
|
-
if (t.mode ===
|
|
1091
|
-
throw new
|
|
1139
|
+
var S, p, M, b, B;
|
|
1140
|
+
const h = () => {
|
|
1141
|
+
if (t.mode === j.DirectPlayback)
|
|
1142
|
+
throw new J("Direct playback is enabled, chat is disabled");
|
|
1092
1143
|
if (d.length >= 800)
|
|
1093
|
-
throw new
|
|
1144
|
+
throw new J("Message cannot be more than 800 characters");
|
|
1094
1145
|
if (d.length === 0)
|
|
1095
|
-
throw new
|
|
1096
|
-
if (
|
|
1097
|
-
throw new
|
|
1098
|
-
if (![
|
|
1099
|
-
if (!
|
|
1100
|
-
throw new
|
|
1101
|
-
if (!
|
|
1102
|
-
throw new
|
|
1146
|
+
throw new J("Message cannot be empty");
|
|
1147
|
+
if (n.chatMode === j.Maintenance)
|
|
1148
|
+
throw new J("Chat is in maintenance mode");
|
|
1149
|
+
if (![j.TextOnly, j.Playground].includes(n.chatMode)) {
|
|
1150
|
+
if (!n.streamingManager)
|
|
1151
|
+
throw new J("Streaming manager is not initialized");
|
|
1152
|
+
if (!n.chat)
|
|
1153
|
+
throw new J("Chat is not initialized");
|
|
1103
1154
|
}
|
|
1104
|
-
},
|
|
1105
|
-
var
|
|
1106
|
-
if (!
|
|
1107
|
-
|
|
1155
|
+
}, k = async () => {
|
|
1156
|
+
var _, T;
|
|
1157
|
+
if (!n.chat) {
|
|
1158
|
+
console.info("create new chat");
|
|
1159
|
+
const u = await ge(c, s, l, n.chatMode, t.persistentChat);
|
|
1108
1160
|
if (!u.chat)
|
|
1109
|
-
throw new
|
|
1110
|
-
|
|
1161
|
+
throw new pe(n.chatMode, !!t.persistentChat);
|
|
1162
|
+
n.chat = u.chat, (T = (_ = t.callbacks).onNewChat) == null || T.call(_, n.chat.id);
|
|
1111
1163
|
}
|
|
1112
|
-
return
|
|
1113
|
-
},
|
|
1114
|
-
var u,
|
|
1115
|
-
return
|
|
1116
|
-
chatMode:
|
|
1117
|
-
streamId: (u =
|
|
1118
|
-
sessionId: (
|
|
1119
|
-
messages:
|
|
1120
|
-
matches:
|
|
1121
|
-
...
|
|
1122
|
-
}) =>
|
|
1164
|
+
return n.chat.id;
|
|
1165
|
+
}, g = async (_, T) => Z(() => {
|
|
1166
|
+
var u, v;
|
|
1167
|
+
return s.chat(c.id, T, {
|
|
1168
|
+
chatMode: n.chatMode,
|
|
1169
|
+
streamId: (u = n.streamingManager) == null ? void 0 : u.streamId,
|
|
1170
|
+
sessionId: (v = n.streamingManager) == null ? void 0 : v.sessionId,
|
|
1171
|
+
messages: _.map(({
|
|
1172
|
+
matches: $,
|
|
1173
|
+
...A
|
|
1174
|
+
}) => A)
|
|
1123
1175
|
}, {
|
|
1124
|
-
...
|
|
1176
|
+
...me(n.chatMode),
|
|
1125
1177
|
skipErrorHandler: !0
|
|
1126
1178
|
});
|
|
1127
1179
|
}, {
|
|
1128
1180
|
limit: 2,
|
|
1129
1181
|
shouldRetryFn: (u) => {
|
|
1130
|
-
var
|
|
1131
|
-
const
|
|
1132
|
-
return !((
|
|
1182
|
+
var A, z, ee, te;
|
|
1183
|
+
const v = (A = u == null ? void 0 : u.message) == null ? void 0 : A.includes("missing or invalid session_id");
|
|
1184
|
+
return !((z = u == null ? void 0 : u.message) == null ? void 0 : z.includes("Stream Error")) && !v ? ((te = (ee = t.callbacks).onError) == null || te.call(ee, u), !1) : !0;
|
|
1133
1185
|
},
|
|
1134
1186
|
onRetry: async () => {
|
|
1135
|
-
await w(), await
|
|
1187
|
+
await w(), await y(!1);
|
|
1136
1188
|
}
|
|
1137
1189
|
});
|
|
1138
1190
|
try {
|
|
1139
|
-
m(),
|
|
1140
|
-
id:
|
|
1191
|
+
m(), h(), n.messages.push({
|
|
1192
|
+
id: X(),
|
|
1141
1193
|
role: "user",
|
|
1142
1194
|
content: d,
|
|
1143
1195
|
created_at: new Date(N.update()).toISOString()
|
|
1144
|
-
}), (
|
|
1145
|
-
const
|
|
1146
|
-
return
|
|
1147
|
-
id:
|
|
1196
|
+
}), (p = (S = t.callbacks).onNewMessage) == null || p.call(S, [...n.messages], "user");
|
|
1197
|
+
const _ = await k(), T = await g([...n.messages], _);
|
|
1198
|
+
return n.messages.push({
|
|
1199
|
+
id: X(),
|
|
1148
1200
|
role: "assistant",
|
|
1149
|
-
content:
|
|
1201
|
+
content: T.result || "",
|
|
1150
1202
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1151
|
-
context:
|
|
1152
|
-
matches:
|
|
1203
|
+
context: T.context,
|
|
1204
|
+
matches: T.matches
|
|
1153
1205
|
}), l.track("agent-message-send", {
|
|
1154
1206
|
event: "success",
|
|
1155
|
-
mode:
|
|
1156
|
-
messages:
|
|
1157
|
-
}),
|
|
1207
|
+
mode: n.chatMode,
|
|
1208
|
+
messages: n.messages.length + 1
|
|
1209
|
+
}), T.result && ((b = (M = t.callbacks).onNewMessage) == null || b.call(M, [...n.messages], "answer"), l.track("agent-message-received", {
|
|
1158
1210
|
latency: N.get(!0),
|
|
1159
|
-
mode:
|
|
1160
|
-
messages:
|
|
1161
|
-
})),
|
|
1162
|
-
} catch (
|
|
1163
|
-
throw ((B =
|
|
1211
|
+
mode: n.chatMode,
|
|
1212
|
+
messages: n.messages.length
|
|
1213
|
+
})), T;
|
|
1214
|
+
} catch (_) {
|
|
1215
|
+
throw ((B = n.messages[n.messages.length - 1]) == null ? void 0 : B.role) === "assistant" && n.messages.pop(), l.track("agent-message-send", {
|
|
1164
1216
|
event: "error",
|
|
1165
|
-
mode:
|
|
1166
|
-
messages:
|
|
1167
|
-
}),
|
|
1217
|
+
mode: n.chatMode,
|
|
1218
|
+
messages: n.messages.length
|
|
1219
|
+
}), _;
|
|
1168
1220
|
}
|
|
1169
1221
|
},
|
|
1170
|
-
rate(d,
|
|
1171
|
-
var
|
|
1172
|
-
const
|
|
1173
|
-
if (
|
|
1174
|
-
if (!
|
|
1222
|
+
rate(d, h, k) {
|
|
1223
|
+
var p, M, b, B;
|
|
1224
|
+
const g = n.messages.find((_) => _.id === d);
|
|
1225
|
+
if (n.chat) {
|
|
1226
|
+
if (!g)
|
|
1175
1227
|
throw new Error("Message not found");
|
|
1176
1228
|
} else
|
|
1177
1229
|
throw new Error("Chat is not initialized");
|
|
1178
|
-
const
|
|
1230
|
+
const S = ((p = g.matches) == null ? void 0 : p.map((_) => [_.document_id, _.id])) ?? [];
|
|
1179
1231
|
return l.track("agent-rate", {
|
|
1180
|
-
event:
|
|
1181
|
-
thumb:
|
|
1182
|
-
knowledge_id: ((
|
|
1183
|
-
mode:
|
|
1184
|
-
matches:
|
|
1185
|
-
score:
|
|
1186
|
-
}),
|
|
1187
|
-
knowledge_id: ((
|
|
1232
|
+
event: k ? "update" : "create",
|
|
1233
|
+
thumb: h === 1 ? "up" : "down",
|
|
1234
|
+
knowledge_id: ((M = c.knowledge) == null ? void 0 : M.id) ?? "",
|
|
1235
|
+
mode: n.chatMode,
|
|
1236
|
+
matches: S,
|
|
1237
|
+
score: h
|
|
1238
|
+
}), k ? s.updateRating(c.id, n.chat.id, k, {
|
|
1239
|
+
knowledge_id: ((b = c.knowledge) == null ? void 0 : b.id) ?? "",
|
|
1188
1240
|
message_id: d,
|
|
1189
|
-
matches:
|
|
1190
|
-
score:
|
|
1191
|
-
}) :
|
|
1241
|
+
matches: S,
|
|
1242
|
+
score: h
|
|
1243
|
+
}) : s.createRating(c.id, n.chat.id, {
|
|
1192
1244
|
knowledge_id: ((B = c.knowledge) == null ? void 0 : B.id) ?? "",
|
|
1193
1245
|
message_id: d,
|
|
1194
|
-
matches:
|
|
1195
|
-
score:
|
|
1246
|
+
matches: S,
|
|
1247
|
+
score: h
|
|
1196
1248
|
});
|
|
1197
1249
|
},
|
|
1198
1250
|
deleteRate(d) {
|
|
1199
|
-
var
|
|
1200
|
-
if (!
|
|
1251
|
+
var h;
|
|
1252
|
+
if (!n.chat)
|
|
1201
1253
|
throw new Error("Chat is not initialized");
|
|
1202
1254
|
return l.track("agent-rate-delete", {
|
|
1203
1255
|
type: "text",
|
|
1204
|
-
chat_id: (
|
|
1256
|
+
chat_id: (h = n.chat) == null ? void 0 : h.id,
|
|
1205
1257
|
id: d,
|
|
1206
|
-
mode:
|
|
1207
|
-
}),
|
|
1258
|
+
mode: n.chatMode
|
|
1259
|
+
}), s.deleteRating(c.id, n.chat.id, d);
|
|
1208
1260
|
},
|
|
1209
|
-
speak(d) {
|
|
1210
|
-
var
|
|
1211
|
-
if (!
|
|
1261
|
+
async speak(d) {
|
|
1262
|
+
var S, p, M, b;
|
|
1263
|
+
if (!n.streamingManager)
|
|
1212
1264
|
throw new Error("Please connect to the agent first");
|
|
1213
|
-
function
|
|
1265
|
+
function h() {
|
|
1214
1266
|
if (typeof d == "string") {
|
|
1215
1267
|
if (!c.presenter.voice)
|
|
1216
1268
|
throw new Error("Presenter voice is not initialized");
|
|
@@ -1233,53 +1285,58 @@ async function ht(e, t) {
|
|
|
1233
1285
|
}
|
|
1234
1286
|
return d;
|
|
1235
1287
|
}
|
|
1236
|
-
const
|
|
1237
|
-
|
|
1238
|
-
id:
|
|
1288
|
+
const k = h();
|
|
1289
|
+
l.track("agent-speak", k), N.update(), (S = n.chat) != null && S.id && k.type === "text" && (n.messages.push({
|
|
1290
|
+
id: X(),
|
|
1239
1291
|
role: "assistant",
|
|
1240
|
-
content:
|
|
1292
|
+
content: k.input,
|
|
1241
1293
|
created_at: new Date(N.get(!0)).toISOString()
|
|
1242
|
-
}), (
|
|
1243
|
-
|
|
1294
|
+
}), (M = (p = t.callbacks).onNewMessage) == null || M.call(p, [...n.messages], "answer"));
|
|
1295
|
+
const g = Be(n.chatMode);
|
|
1296
|
+
return n.chat && g ? {
|
|
1297
|
+
duration: 0,
|
|
1298
|
+
status: "success"
|
|
1299
|
+
} : n.streamingManager.speak({
|
|
1300
|
+
script: k,
|
|
1244
1301
|
metadata: {
|
|
1245
|
-
chat_id: (
|
|
1302
|
+
chat_id: (b = n.chat) == null ? void 0 : b.id,
|
|
1246
1303
|
agent_id: c.id
|
|
1247
1304
|
}
|
|
1248
1305
|
});
|
|
1249
1306
|
}
|
|
1250
1307
|
};
|
|
1251
1308
|
}
|
|
1252
|
-
function
|
|
1309
|
+
function pt(e, t, r) {
|
|
1253
1310
|
const {
|
|
1254
1311
|
getById: a
|
|
1255
|
-
} =
|
|
1312
|
+
} = ue(t, r || q);
|
|
1256
1313
|
return a(e);
|
|
1257
1314
|
}
|
|
1258
1315
|
export {
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1316
|
+
K as AgentActivityState,
|
|
1317
|
+
Re as AgentStatus,
|
|
1318
|
+
pe as ChatCreationFailed,
|
|
1319
|
+
j as ChatMode,
|
|
1320
|
+
ve as ChatModeDowngraded,
|
|
1321
|
+
U as ChatProgress,
|
|
1322
|
+
I as ConnectionState,
|
|
1266
1323
|
W as ConnectivityState,
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1324
|
+
ne as DataChannelSignalMap,
|
|
1325
|
+
Me as DocumentType,
|
|
1326
|
+
Se as KnowledgeType,
|
|
1327
|
+
De as PlanGroup,
|
|
1328
|
+
Te as Providers,
|
|
1329
|
+
_e as RateState,
|
|
1330
|
+
Y as StreamEvents,
|
|
1274
1331
|
F as StreamType,
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1332
|
+
C as StreamingState,
|
|
1333
|
+
Ee as Subject,
|
|
1334
|
+
Ce as UserPlan,
|
|
1335
|
+
J as ValidationError,
|
|
1336
|
+
oe as VideoType,
|
|
1337
|
+
je as VoiceAccess,
|
|
1338
|
+
ke as WsError,
|
|
1339
|
+
yt as createAgentManager,
|
|
1340
|
+
pt as getAgent,
|
|
1341
|
+
Ie as mapVideoType
|
|
1285
1342
|
};
|