@d-id/client-sdk 1.1.0-beta.6 → 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 +695 -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/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/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var H = (e, t,
|
|
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
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
14
|
H(this, "kind");
|
|
15
15
|
H(this, "description");
|
|
16
16
|
H(this, "error");
|
|
17
|
-
this.kind =
|
|
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 Q {
|
|
|
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 Q {
|
|
|
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 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 || {}),
|
|
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
82
|
async function Z(e, t) {
|
|
83
|
-
const
|
|
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,200 +90,218 @@ async function Z(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 O(e, t = q,
|
|
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
|
-
const
|
|
145
|
-
throw
|
|
144
|
+
const f = new Error(l);
|
|
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
|
+
return a(o, {
|
|
169
|
+
...n,
|
|
170
|
+
body: JSON.stringify(i),
|
|
171
|
+
method: "PUT"
|
|
172
|
+
});
|
|
173
|
+
},
|
|
174
|
+
delete(o, i, n) {
|
|
168
175
|
return a(o, {
|
|
169
|
-
...
|
|
170
|
-
body: JSON.stringify(
|
|
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 = O(e, `${t}/agents`,
|
|
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);
|
|
188
203
|
},
|
|
189
|
-
|
|
190
|
-
return a.
|
|
204
|
+
create(o, i) {
|
|
205
|
+
return a.post("/", o, i);
|
|
191
206
|
},
|
|
192
|
-
|
|
193
|
-
return a.get(`/${o}`,
|
|
207
|
+
getAgents(o, i) {
|
|
208
|
+
return a.get(`/${o ? `?tag=${o}` : ""}`, i).then((n) => n ?? []);
|
|
194
209
|
},
|
|
195
|
-
|
|
196
|
-
return a.
|
|
210
|
+
getById(o, i) {
|
|
211
|
+
return a.get(`/${o}`, i);
|
|
197
212
|
},
|
|
198
|
-
|
|
199
|
-
return a.
|
|
213
|
+
delete(o, i) {
|
|
214
|
+
return a.delete(`/${o}`, void 0, i);
|
|
200
215
|
},
|
|
201
|
-
|
|
202
|
-
return a.
|
|
216
|
+
update(o, i, n) {
|
|
217
|
+
return a.patch(`/${o}`, i, n);
|
|
203
218
|
},
|
|
204
|
-
|
|
205
|
-
return a.post(`/${o}/chat
|
|
219
|
+
newChat(o, i, n) {
|
|
220
|
+
return a.post(`/${o}/chat`, i, n);
|
|
206
221
|
},
|
|
207
|
-
|
|
208
|
-
return a.post(`/${o}/chat/${
|
|
222
|
+
chat(o, i, n, s) {
|
|
223
|
+
return a.post(`/${o}/chat/${i}`, n, s);
|
|
209
224
|
},
|
|
210
|
-
|
|
211
|
-
return a.
|
|
225
|
+
createRating(o, i, n, s) {
|
|
226
|
+
return a.post(`/${o}/chat/${i}/ratings`, n, s);
|
|
212
227
|
},
|
|
213
|
-
|
|
214
|
-
return a.
|
|
228
|
+
updateRating(o, i, n, s, c) {
|
|
229
|
+
return a.patch(`/${o}/chat/${i}/ratings/${n}`, s, c);
|
|
215
230
|
},
|
|
216
|
-
|
|
217
|
-
return a.
|
|
231
|
+
deleteRating(o, i, n, s) {
|
|
232
|
+
return a.delete(`/${o}/chat/${i}/ratings/${n}`, s);
|
|
233
|
+
},
|
|
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
|
|
242
|
-
var c, l,
|
|
258
|
+
const Fe = (e) => e.reduce((t, r) => t + r, 0), Je = (e) => Fe(e) / e.length;
|
|
259
|
+
function Ue(e, t, r) {
|
|
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
|
-
stitch: (t == null ? void 0 : t.presenter.type) === "talk" ? (
|
|
265
|
-
...
|
|
282
|
+
stitch: (t == null ? void 0 : t.presenter.type) === "talk" ? (f = t == null ? void 0 : t.presenter) == null ? void 0 : f.stitch : void 0,
|
|
283
|
+
...r
|
|
266
284
|
};
|
|
267
285
|
}
|
|
268
286
|
let V = {};
|
|
269
|
-
const
|
|
270
|
-
function
|
|
271
|
-
var
|
|
272
|
-
const t = window != null && window.hasOwnProperty("DID_AGENTS_API") ? "agents-ui" : "agents-sdk",
|
|
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,
|
|
286
|
-
starterQuestionsCount: (
|
|
304
|
+
starterQuestionsCount: (f = (l = e.agent.knowledge) == null ? void 0 : l.starter_message) == null ? void 0 : f.length,
|
|
287
305
|
topicsToAvoid: a == null ? void 0 : a.topics_to_avoid,
|
|
288
306
|
maxResponseLength: a == null ? void 0 : a.max_response_length
|
|
289
307
|
};
|
|
@@ -292,34 +310,34 @@ function We(e) {
|
|
|
292
310
|
additionalProperties: {},
|
|
293
311
|
isEnabled: e.isEnabled ?? !0,
|
|
294
312
|
getRandom: () => Math.random().toString(16).slice(2),
|
|
295
|
-
enrich(
|
|
296
|
-
const
|
|
297
|
-
if (
|
|
313
|
+
enrich(m) {
|
|
314
|
+
const D = {};
|
|
315
|
+
if (m && typeof m != "object")
|
|
298
316
|
throw new Error("properties must be a flat json object");
|
|
299
|
-
for (let y in
|
|
300
|
-
(typeof
|
|
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
|
|
304
322
|
};
|
|
305
323
|
},
|
|
306
|
-
async track(
|
|
324
|
+
async track(m, D) {
|
|
307
325
|
if (!this.isEnabled)
|
|
308
326
|
return Promise.resolve();
|
|
309
327
|
const {
|
|
310
328
|
audioPath: y,
|
|
311
|
-
...
|
|
312
|
-
} =
|
|
329
|
+
...w
|
|
330
|
+
} = D || {}, R = {
|
|
313
331
|
method: "POST",
|
|
314
332
|
headers: {
|
|
315
333
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
316
334
|
},
|
|
317
335
|
body: new URLSearchParams({
|
|
318
336
|
data: JSON.stringify([{
|
|
319
|
-
event:
|
|
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 We(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(
|
|
342
|
-
V[
|
|
359
|
+
linkTrack(m, D, y, w) {
|
|
360
|
+
V[m] || (V[m] = {
|
|
343
361
|
events: {},
|
|
344
362
|
resolvedDependencies: []
|
|
345
|
-
}),
|
|
346
|
-
const
|
|
347
|
-
if (
|
|
348
|
-
props:
|
|
349
|
-
},
|
|
350
|
-
const
|
|
351
|
-
...
|
|
352
|
-
...
|
|
353
|
-
} :
|
|
354
|
-
this.track(
|
|
355
|
-
delete
|
|
363
|
+
}), w.includes(y) || w.push(y);
|
|
364
|
+
const R = V[m];
|
|
365
|
+
if (R.events[y] = {
|
|
366
|
+
props: D
|
|
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 Ue() {
|
|
|
366
384
|
get: (t = !1) => t ? Date.now() - e : e
|
|
367
385
|
};
|
|
368
386
|
}
|
|
369
|
-
const
|
|
370
|
-
function
|
|
387
|
+
const N = Ke();
|
|
388
|
+
function me(e) {
|
|
371
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 || {},
|
|
416
|
-
|
|
417
|
-
console.error(
|
|
418
|
-
},
|
|
419
|
-
|
|
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);
|
|
436
|
+
}, f.onopen = (m) => {
|
|
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
|
|
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", y,
|
|
496
|
-
else if (
|
|
497
|
-
const
|
|
498
|
-
|
|
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", {
|
|
499
518
|
...y,
|
|
500
|
-
event:
|
|
519
|
+
event: w
|
|
501
520
|
}) : e.linkTrack("agent-video", {
|
|
502
521
|
...y,
|
|
503
|
-
event:
|
|
504
|
-
},
|
|
522
|
+
event: w
|
|
523
|
+
}, n, ["done"]);
|
|
505
524
|
}
|
|
506
|
-
|
|
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 = O(e, `${t}/agents/${
|
|
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 = O(e, `${t}/agents/${
|
|
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 Oe(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 et(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 G = 100,
|
|
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
|
|
717
|
-
a =
|
|
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;
|
|
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,25 +753,25 @@ function st() {
|
|
|
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
|
-
const
|
|
738
|
-
isReceiving:
|
|
739
|
-
avgJitterDelayInInterval:
|
|
740
|
-
freezeCount:
|
|
741
|
-
} =
|
|
742
|
-
if (
|
|
743
|
-
c = 0,
|
|
744
|
-
else if (l && (c++, c >=
|
|
745
|
-
const h =
|
|
746
|
-
a == null || a(
|
|
760
|
+
const R = await e.getStats(), {
|
|
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":
|
|
@@ -769,153 +792,154 @@ function re(e) {
|
|
|
769
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 ===
|
|
820
|
+
o === F.Legacy ? ut({
|
|
798
821
|
statsSignal: e,
|
|
799
822
|
dataChannelSignal: t,
|
|
800
|
-
onVideoStateChange:
|
|
801
|
-
report:
|
|
802
|
-
}) : o ===
|
|
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:
|
|
815
|
-
analytics:
|
|
837
|
+
baseURL: i = q,
|
|
838
|
+
analytics: n
|
|
816
839
|
}) {
|
|
817
|
-
|
|
818
|
-
let
|
|
840
|
+
he = r;
|
|
841
|
+
let s = !1, c = !1, l = C.Stop, f = C.Stop, m = W.Unknown;
|
|
842
|
+
console.log("OFEK TEST");
|
|
819
843
|
const {
|
|
820
|
-
startConnection:
|
|
844
|
+
startConnection: D,
|
|
821
845
|
sendStreamRequest: y,
|
|
822
|
-
close:
|
|
823
|
-
createStream:
|
|
824
|
-
addIceCandidate:
|
|
825
|
-
} = t.videoType ===
|
|
826
|
-
id:
|
|
827
|
-
offer:
|
|
828
|
-
ice_servers:
|
|
846
|
+
close: w,
|
|
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,
|
|
851
|
+
offer: P,
|
|
852
|
+
ice_servers: d,
|
|
829
853
|
session_id: h,
|
|
830
|
-
fluent:
|
|
831
|
-
} = await
|
|
832
|
-
iceServers:
|
|
833
|
-
}),
|
|
854
|
+
fluent: k
|
|
855
|
+
} = await R(t), g = new lt({
|
|
856
|
+
iceServers: d
|
|
857
|
+
}), S = g.createDataChannel("JanusDataChannel");
|
|
834
858
|
if (!h)
|
|
835
859
|
throw new Error("Could not create session_id");
|
|
836
|
-
const
|
|
837
|
-
|
|
838
|
-
"stream-type":
|
|
860
|
+
const p = k ? F.Fluent : F.Legacy;
|
|
861
|
+
n.enrich({
|
|
862
|
+
"stream-type": p
|
|
839
863
|
});
|
|
840
|
-
const
|
|
841
|
-
var
|
|
842
|
-
|
|
843
|
-
},
|
|
844
|
-
statsSignal:
|
|
845
|
-
dataChannelSignal:
|
|
864
|
+
const M = t.stream_warmup && !k, b = () => s, B = () => {
|
|
865
|
+
var u;
|
|
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,
|
|
846
870
|
onVideoStateChange: a.onVideoStateChange,
|
|
847
871
|
onAgentActivityStateChange: a.onAgentActivityStateChange,
|
|
848
|
-
report:
|
|
849
|
-
streamType:
|
|
850
|
-
}), (
|
|
851
|
-
var
|
|
852
|
-
return (
|
|
853
|
-
},
|
|
854
|
-
g.onicecandidate = (
|
|
855
|
-
var
|
|
856
|
-
|
|
872
|
+
report: v,
|
|
873
|
+
streamType: p
|
|
874
|
+
}), (u) => {
|
|
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);
|
|
857
881
|
try {
|
|
858
|
-
|
|
859
|
-
candidate:
|
|
860
|
-
sdpMid:
|
|
861
|
-
sdpMLineIndex:
|
|
862
|
-
}, h) :
|
|
882
|
+
u.candidate && u.candidate.sdpMid && u.candidate.sdpMLineIndex !== null ? L(E, {
|
|
883
|
+
candidate: u.candidate.candidate,
|
|
884
|
+
sdpMid: u.candidate.sdpMid,
|
|
885
|
+
sdpMLineIndex: u.candidate.sdpMLineIndex
|
|
886
|
+
}, h) : L(E, {
|
|
863
887
|
candidate: null
|
|
864
888
|
}, h);
|
|
865
889
|
} catch ($) {
|
|
866
|
-
(
|
|
867
|
-
streamId:
|
|
890
|
+
(v = a.onError) == null || v.call(a, $, {
|
|
891
|
+
streamId: E
|
|
868
892
|
});
|
|
869
893
|
}
|
|
870
|
-
},
|
|
871
|
-
c = !0, (!
|
|
872
|
-
},
|
|
873
|
-
|
|
874
|
-
statsSignal:
|
|
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,
|
|
875
899
|
dataChannelSignal: l,
|
|
876
900
|
onVideoStateChange: a.onVideoStateChange,
|
|
877
901
|
onAgentActivityStateChange: a.onAgentActivityStateChange,
|
|
878
|
-
streamType:
|
|
902
|
+
streamType: p
|
|
879
903
|
}));
|
|
880
904
|
}, g.oniceconnectionstatechange = () => {
|
|
881
|
-
var
|
|
882
|
-
|
|
883
|
-
const
|
|
884
|
-
|
|
885
|
-
}, g.ontrack = (
|
|
886
|
-
var
|
|
887
|
-
|
|
888
|
-
}, await g.setRemoteDescription(
|
|
889
|
-
const
|
|
890
|
-
return
|
|
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"), {
|
|
891
915
|
/**
|
|
892
916
|
* Method to send request to server to get clip or talk depend on you payload
|
|
893
917
|
* @param payload
|
|
894
918
|
*/
|
|
895
|
-
speak(
|
|
896
|
-
return y(
|
|
919
|
+
speak(u) {
|
|
920
|
+
return y(E, h, u);
|
|
897
921
|
},
|
|
898
922
|
/**
|
|
899
923
|
* Method to close RTC connection
|
|
900
924
|
*/
|
|
901
925
|
async disconnect() {
|
|
902
|
-
var
|
|
903
|
-
if (
|
|
926
|
+
var u, v, $;
|
|
927
|
+
if (E) {
|
|
904
928
|
const A = re(g.iceConnectionState);
|
|
905
929
|
if (g) {
|
|
906
930
|
if (A === I.New) {
|
|
907
|
-
(
|
|
931
|
+
(u = a.onVideoStateChange) == null || u.call(a, C.Stop), clearInterval(_);
|
|
908
932
|
return;
|
|
909
933
|
}
|
|
910
934
|
g.close(), g.oniceconnectionstatechange = null, g.onnegotiationneeded = null, g.onicecandidate = null, g.ontrack = null;
|
|
911
935
|
}
|
|
912
936
|
try {
|
|
913
|
-
A === I.Connected && await
|
|
937
|
+
A === I.Connected && await w(E, h).catch((z) => {
|
|
914
938
|
});
|
|
915
|
-
} catch (
|
|
916
|
-
|
|
939
|
+
} catch (z) {
|
|
940
|
+
x("Error on close stream connection", z);
|
|
917
941
|
}
|
|
918
|
-
(
|
|
942
|
+
(v = a.onVideoStateChange) == null || v.call(a, C.Stop), ($ = a.onAgentActivityStateChange) == null || $.call(a, K.Idle), clearInterval(_);
|
|
919
943
|
}
|
|
920
944
|
},
|
|
921
945
|
/**
|
|
@@ -925,230 +949,253 @@ async function ut(e, t, {
|
|
|
925
949
|
/**
|
|
926
950
|
* Id of current RTC stream
|
|
927
951
|
*/
|
|
928
|
-
streamId:
|
|
929
|
-
streamType:
|
|
952
|
+
streamId: E,
|
|
953
|
+
streamType: p
|
|
930
954
|
};
|
|
931
955
|
}
|
|
932
|
-
function
|
|
956
|
+
function gt(e, t) {
|
|
933
957
|
const {
|
|
934
|
-
streamOptions:
|
|
935
|
-
} = t ?? {};
|
|
958
|
+
streamOptions: r
|
|
959
|
+
} = t ?? {}, o = new URLSearchParams(window.location.search).get("conn_id") || void 0;
|
|
936
960
|
return {
|
|
937
|
-
videoType:
|
|
938
|
-
output_resolution:
|
|
939
|
-
session_timeout:
|
|
940
|
-
stream_warmup:
|
|
941
|
-
compatibility_mode:
|
|
942
|
-
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
|
|
943
968
|
};
|
|
944
969
|
}
|
|
945
|
-
function
|
|
946
|
-
|
|
970
|
+
function ie(e, t, r, a, o) {
|
|
971
|
+
N.get() > 0 && (e === C.Start ? a.linkTrack("agent-video", {
|
|
947
972
|
event: "start",
|
|
948
|
-
latency:
|
|
973
|
+
latency: N.get(!0),
|
|
949
974
|
"stream-type": o
|
|
950
|
-
}, "start", [Y.StreamVideoCreated]) : e ===
|
|
975
|
+
}, "start", [Y.StreamVideoCreated]) : e === C.Stop && a.linkTrack("agent-video", {
|
|
951
976
|
event: "stop",
|
|
952
977
|
is_greenscreen: t.presenter.type === "clip" && t.presenter.is_greenscreen,
|
|
953
978
|
background: t.presenter.type === "clip" && t.presenter.background,
|
|
954
979
|
"stream-type": o,
|
|
955
|
-
...
|
|
980
|
+
...r
|
|
956
981
|
}, "done", [Y.StreamVideoDone]));
|
|
957
982
|
}
|
|
958
|
-
function
|
|
959
|
-
return
|
|
983
|
+
function se(e, t, r) {
|
|
984
|
+
return N.reset(), new Promise(async (a, o) => {
|
|
960
985
|
try {
|
|
961
|
-
const
|
|
986
|
+
const i = await mt(e.id, gt(e, t), {
|
|
962
987
|
...t,
|
|
963
|
-
analytics:
|
|
988
|
+
analytics: r,
|
|
964
989
|
callbacks: {
|
|
965
990
|
...t.callbacks,
|
|
966
|
-
onConnectionStateChange: (
|
|
967
|
-
var
|
|
968
|
-
(c = (
|
|
991
|
+
onConnectionStateChange: (n) => {
|
|
992
|
+
var s, c;
|
|
993
|
+
(c = (s = t.callbacks).onConnectionStateChange) == null || c.call(s, n), n === I.Connected && a(i);
|
|
969
994
|
},
|
|
970
|
-
onVideoStateChange: (
|
|
995
|
+
onVideoStateChange: (n, s) => {
|
|
971
996
|
var c, l;
|
|
972
|
-
(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);
|
|
973
998
|
},
|
|
974
|
-
onAgentActivityStateChange: (
|
|
975
|
-
var
|
|
976
|
-
(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);
|
|
977
1002
|
}
|
|
978
1003
|
}
|
|
979
1004
|
});
|
|
980
|
-
} catch (
|
|
981
|
-
o(
|
|
1005
|
+
} catch (i) {
|
|
1006
|
+
o(i);
|
|
982
1007
|
}
|
|
983
1008
|
});
|
|
984
1009
|
}
|
|
985
|
-
async function
|
|
986
|
-
var
|
|
987
|
-
const
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
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
|
|
994
1023
|
};
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
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
|
+
}
|
|
1000
1039
|
}
|
|
1001
|
-
async function
|
|
1002
|
-
var
|
|
1003
|
-
let
|
|
1004
|
-
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 = {
|
|
1005
1044
|
messages: [],
|
|
1006
1045
|
chatMode: t.mode || j.Functional
|
|
1007
|
-
},
|
|
1046
|
+
}, s = ue(t.auth, i, t.callbacks.onError), c = await s.getById(e), l = He({
|
|
1008
1047
|
token: a,
|
|
1009
1048
|
agent: c,
|
|
1010
1049
|
isEnabled: t.enableAnalitics,
|
|
1011
1050
|
distinctId: t.distinctId
|
|
1012
1051
|
}), {
|
|
1013
|
-
onMessage:
|
|
1014
|
-
clearQueue:
|
|
1015
|
-
} =
|
|
1052
|
+
onMessage: f,
|
|
1053
|
+
clearQueue: m
|
|
1054
|
+
} = Ge(l, n, t, c, () => {
|
|
1016
1055
|
var d;
|
|
1017
|
-
return (d =
|
|
1056
|
+
return (d = n.socketManager) == null ? void 0 : d.disconnect();
|
|
1018
1057
|
});
|
|
1019
|
-
|
|
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", {
|
|
1020
1065
|
event: "loaded",
|
|
1021
|
-
...
|
|
1066
|
+
...Ne(c)
|
|
1022
1067
|
});
|
|
1023
|
-
async function
|
|
1024
|
-
var
|
|
1025
|
-
(
|
|
1026
|
-
const
|
|
1027
|
-
onMessage:
|
|
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, {
|
|
1072
|
+
onMessage: f,
|
|
1028
1073
|
onError: t.callbacks.onError
|
|
1029
|
-
}),
|
|
1074
|
+
}), k = Z(() => ht(c, t, s, l, n.chat), {
|
|
1030
1075
|
limit: 3,
|
|
1031
|
-
timeout:
|
|
1076
|
+
timeout: Pe,
|
|
1032
1077
|
timeoutErrorMessage: "Timeout initializing the stream",
|
|
1033
1078
|
// Retry on all errors except for connection errors and rate limit errors, these are already handled in client level.
|
|
1034
|
-
shouldRetryFn: (
|
|
1079
|
+
shouldRetryFn: ($) => ($ == null ? void 0 : $.message) !== "Could not connect" && $.status !== 429,
|
|
1035
1080
|
delayMs: 1e3
|
|
1036
|
-
}).catch((
|
|
1037
|
-
var
|
|
1038
|
-
throw
|
|
1039
|
-
}), [
|
|
1040
|
-
streamingManager:
|
|
1041
|
-
chat:
|
|
1042
|
-
}] = await Promise.all([
|
|
1043
|
-
|
|
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);
|
|
1044
1089
|
}
|
|
1045
|
-
async function
|
|
1046
|
-
var d,
|
|
1047
|
-
(d =
|
|
1090
|
+
async function w() {
|
|
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);
|
|
1048
1093
|
}
|
|
1049
|
-
async function
|
|
1050
|
-
var
|
|
1051
|
-
d !==
|
|
1094
|
+
async function R(d) {
|
|
1095
|
+
var h, k;
|
|
1096
|
+
d !== n.chatMode && (l.track("agent-mode-change", {
|
|
1052
1097
|
mode: d
|
|
1053
|
-
}),
|
|
1098
|
+
}), n.chatMode = d, n.chatMode !== j.Functional && await w(), (k = (h = t.callbacks).onModeChange) == null || k.call(h, d));
|
|
1054
1099
|
}
|
|
1055
1100
|
return {
|
|
1056
1101
|
agent: c,
|
|
1102
|
+
getInviteLink: D,
|
|
1057
1103
|
getStreamType: () => {
|
|
1058
1104
|
var d;
|
|
1059
|
-
return (d =
|
|
1105
|
+
return (d = n.streamingManager) == null ? void 0 : d.streamType;
|
|
1060
1106
|
},
|
|
1061
|
-
starterMessages: ((
|
|
1062
|
-
getSTTToken: () =>
|
|
1063
|
-
changeMode:
|
|
1107
|
+
starterMessages: ((P = c.knowledge) == null ? void 0 : P.starter_message) || [],
|
|
1108
|
+
getSTTToken: () => s.getSTTToken(c.id),
|
|
1109
|
+
changeMode: R,
|
|
1064
1110
|
enrichAnalytics: l.enrich,
|
|
1065
1111
|
async connect() {
|
|
1066
1112
|
var d;
|
|
1067
|
-
await
|
|
1113
|
+
await y(!0), l.track("agent-chat", {
|
|
1068
1114
|
event: "connect",
|
|
1069
|
-
chatId: (d =
|
|
1115
|
+
chatId: (d = n.chat) == null ? void 0 : d.id,
|
|
1070
1116
|
agentId: c.id,
|
|
1071
|
-
mode:
|
|
1117
|
+
mode: n.chatMode
|
|
1072
1118
|
});
|
|
1073
1119
|
},
|
|
1074
1120
|
async reconnect() {
|
|
1075
1121
|
var d;
|
|
1076
|
-
await
|
|
1122
|
+
await w(), await y(!1), l.track("agent-chat", {
|
|
1077
1123
|
event: "reconnect",
|
|
1078
|
-
chatId: (d =
|
|
1124
|
+
chatId: (d = n.chat) == null ? void 0 : d.id,
|
|
1079
1125
|
agentId: c.id,
|
|
1080
|
-
mode:
|
|
1126
|
+
mode: n.chatMode
|
|
1081
1127
|
});
|
|
1082
1128
|
},
|
|
1083
1129
|
async disconnect() {
|
|
1084
1130
|
var d;
|
|
1085
|
-
await
|
|
1131
|
+
await w(), l.track("agent-chat", {
|
|
1086
1132
|
event: "disconnect",
|
|
1087
|
-
chatId: (d =
|
|
1133
|
+
chatId: (d = n.chat) == null ? void 0 : d.id,
|
|
1088
1134
|
agentId: c.id,
|
|
1089
|
-
mode:
|
|
1135
|
+
mode: n.chatMode
|
|
1090
1136
|
});
|
|
1091
1137
|
},
|
|
1092
1138
|
async chat(d) {
|
|
1093
|
-
var
|
|
1094
|
-
const
|
|
1139
|
+
var S, p, M, b, B;
|
|
1140
|
+
const h = () => {
|
|
1095
1141
|
if (t.mode === j.DirectPlayback)
|
|
1096
|
-
throw new
|
|
1142
|
+
throw new J("Direct playback is enabled, chat is disabled");
|
|
1097
1143
|
if (d.length >= 800)
|
|
1098
|
-
throw new
|
|
1144
|
+
throw new J("Message cannot be more than 800 characters");
|
|
1099
1145
|
if (d.length === 0)
|
|
1100
|
-
throw new
|
|
1101
|
-
if (
|
|
1102
|
-
throw new
|
|
1103
|
-
if (![j.TextOnly, j.Playground].includes(
|
|
1104
|
-
if (!
|
|
1105
|
-
throw new
|
|
1106
|
-
if (!
|
|
1107
|
-
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");
|
|
1108
1154
|
}
|
|
1109
|
-
},
|
|
1110
|
-
var
|
|
1111
|
-
if (!
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
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);
|
|
1160
|
+
if (!u.chat)
|
|
1161
|
+
throw new pe(n.chatMode, !!t.persistentChat);
|
|
1162
|
+
n.chat = u.chat, (T = (_ = t.callbacks).onNewChat) == null || T.call(_, n.chat.id);
|
|
1116
1163
|
}
|
|
1117
|
-
return
|
|
1118
|
-
},
|
|
1119
|
-
var
|
|
1120
|
-
return
|
|
1121
|
-
chatMode:
|
|
1122
|
-
streamId: (
|
|
1123
|
-
sessionId: (
|
|
1124
|
-
messages:
|
|
1125
|
-
matches:
|
|
1126
|
-
|
|
1127
|
-
}) =>
|
|
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)
|
|
1128
1175
|
}, {
|
|
1129
|
-
...
|
|
1176
|
+
...me(n.chatMode),
|
|
1130
1177
|
skipErrorHandler: !0
|
|
1131
1178
|
});
|
|
1132
1179
|
}, {
|
|
1133
1180
|
limit: 2,
|
|
1134
|
-
shouldRetryFn: (
|
|
1135
|
-
var
|
|
1136
|
-
const
|
|
1137
|
-
return !((
|
|
1181
|
+
shouldRetryFn: (u) => {
|
|
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;
|
|
1138
1185
|
},
|
|
1139
1186
|
onRetry: async () => {
|
|
1140
|
-
await
|
|
1187
|
+
await w(), await y(!1);
|
|
1141
1188
|
}
|
|
1142
1189
|
});
|
|
1143
1190
|
try {
|
|
1144
|
-
|
|
1191
|
+
m(), h(), n.messages.push({
|
|
1145
1192
|
id: X(),
|
|
1146
1193
|
role: "user",
|
|
1147
1194
|
content: d,
|
|
1148
|
-
created_at: new Date(
|
|
1149
|
-
}), (
|
|
1150
|
-
const
|
|
1151
|
-
return
|
|
1195
|
+
created_at: new Date(N.update()).toISOString()
|
|
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({
|
|
1152
1199
|
id: X(),
|
|
1153
1200
|
role: "assistant",
|
|
1154
1201
|
content: T.result || "",
|
|
@@ -1157,65 +1204,65 @@ async function wt(e, t) {
|
|
|
1157
1204
|
matches: T.matches
|
|
1158
1205
|
}), l.track("agent-message-send", {
|
|
1159
1206
|
event: "success",
|
|
1160
|
-
mode:
|
|
1161
|
-
messages:
|
|
1162
|
-
}), T.result && ((
|
|
1163
|
-
latency:
|
|
1164
|
-
mode:
|
|
1165
|
-
messages:
|
|
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", {
|
|
1210
|
+
latency: N.get(!0),
|
|
1211
|
+
mode: n.chatMode,
|
|
1212
|
+
messages: n.messages.length
|
|
1166
1213
|
})), T;
|
|
1167
|
-
} catch (
|
|
1168
|
-
throw ((
|
|
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", {
|
|
1169
1216
|
event: "error",
|
|
1170
|
-
mode:
|
|
1171
|
-
messages:
|
|
1172
|
-
}),
|
|
1217
|
+
mode: n.chatMode,
|
|
1218
|
+
messages: n.messages.length
|
|
1219
|
+
}), _;
|
|
1173
1220
|
}
|
|
1174
1221
|
},
|
|
1175
|
-
rate(d,
|
|
1176
|
-
var
|
|
1177
|
-
const
|
|
1178
|
-
if (
|
|
1179
|
-
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)
|
|
1180
1227
|
throw new Error("Message not found");
|
|
1181
1228
|
} else
|
|
1182
1229
|
throw new Error("Chat is not initialized");
|
|
1183
|
-
const
|
|
1230
|
+
const S = ((p = g.matches) == null ? void 0 : p.map((_) => [_.document_id, _.id])) ?? [];
|
|
1184
1231
|
return l.track("agent-rate", {
|
|
1185
|
-
event:
|
|
1186
|
-
thumb:
|
|
1187
|
-
knowledge_id: ((
|
|
1188
|
-
mode:
|
|
1189
|
-
matches:
|
|
1190
|
-
score:
|
|
1191
|
-
}),
|
|
1192
|
-
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) ?? "",
|
|
1193
1240
|
message_id: d,
|
|
1194
|
-
matches:
|
|
1195
|
-
score:
|
|
1196
|
-
}) :
|
|
1197
|
-
knowledge_id: ((
|
|
1241
|
+
matches: S,
|
|
1242
|
+
score: h
|
|
1243
|
+
}) : s.createRating(c.id, n.chat.id, {
|
|
1244
|
+
knowledge_id: ((B = c.knowledge) == null ? void 0 : B.id) ?? "",
|
|
1198
1245
|
message_id: d,
|
|
1199
|
-
matches:
|
|
1200
|
-
score:
|
|
1246
|
+
matches: S,
|
|
1247
|
+
score: h
|
|
1201
1248
|
});
|
|
1202
1249
|
},
|
|
1203
1250
|
deleteRate(d) {
|
|
1204
|
-
var
|
|
1205
|
-
if (!
|
|
1251
|
+
var h;
|
|
1252
|
+
if (!n.chat)
|
|
1206
1253
|
throw new Error("Chat is not initialized");
|
|
1207
1254
|
return l.track("agent-rate-delete", {
|
|
1208
1255
|
type: "text",
|
|
1209
|
-
chat_id: (
|
|
1256
|
+
chat_id: (h = n.chat) == null ? void 0 : h.id,
|
|
1210
1257
|
id: d,
|
|
1211
|
-
mode:
|
|
1212
|
-
}),
|
|
1258
|
+
mode: n.chatMode
|
|
1259
|
+
}), s.deleteRating(c.id, n.chat.id, d);
|
|
1213
1260
|
},
|
|
1214
1261
|
async speak(d) {
|
|
1215
|
-
var
|
|
1216
|
-
if (!
|
|
1262
|
+
var S, p, M, b;
|
|
1263
|
+
if (!n.streamingManager)
|
|
1217
1264
|
throw new Error("Please connect to the agent first");
|
|
1218
|
-
function
|
|
1265
|
+
function h() {
|
|
1219
1266
|
if (typeof d == "string") {
|
|
1220
1267
|
if (!c.presenter.voice)
|
|
1221
1268
|
throw new Error("Presenter voice is not initialized");
|
|
@@ -1238,58 +1285,58 @@ async function wt(e, t) {
|
|
|
1238
1285
|
}
|
|
1239
1286
|
return d;
|
|
1240
1287
|
}
|
|
1241
|
-
const
|
|
1242
|
-
l.track("agent-speak",
|
|
1288
|
+
const k = h();
|
|
1289
|
+
l.track("agent-speak", k), N.update(), (S = n.chat) != null && S.id && k.type === "text" && (n.messages.push({
|
|
1243
1290
|
id: X(),
|
|
1244
1291
|
role: "assistant",
|
|
1245
|
-
content:
|
|
1246
|
-
created_at: new Date(
|
|
1247
|
-
}), (
|
|
1248
|
-
const
|
|
1249
|
-
return
|
|
1292
|
+
content: k.input,
|
|
1293
|
+
created_at: new Date(N.get(!0)).toISOString()
|
|
1294
|
+
}), (M = (p = t.callbacks).onNewMessage) == null || M.call(p, [...n.messages], "answer"));
|
|
1295
|
+
const g = Be(n.chatMode);
|
|
1296
|
+
return n.chat && g ? {
|
|
1250
1297
|
duration: 0,
|
|
1251
1298
|
status: "success"
|
|
1252
|
-
} :
|
|
1253
|
-
script:
|
|
1299
|
+
} : n.streamingManager.speak({
|
|
1300
|
+
script: k,
|
|
1254
1301
|
metadata: {
|
|
1255
|
-
chat_id: (
|
|
1302
|
+
chat_id: (b = n.chat) == null ? void 0 : b.id,
|
|
1256
1303
|
agent_id: c.id
|
|
1257
1304
|
}
|
|
1258
1305
|
});
|
|
1259
1306
|
}
|
|
1260
1307
|
};
|
|
1261
1308
|
}
|
|
1262
|
-
function pt(e, t,
|
|
1309
|
+
function pt(e, t, r) {
|
|
1263
1310
|
const {
|
|
1264
1311
|
getById: a
|
|
1265
|
-
} =
|
|
1312
|
+
} = ue(t, r || q);
|
|
1266
1313
|
return a(e);
|
|
1267
1314
|
}
|
|
1268
1315
|
export {
|
|
1269
1316
|
K as AgentActivityState,
|
|
1270
|
-
|
|
1271
|
-
|
|
1317
|
+
Re as AgentStatus,
|
|
1318
|
+
pe as ChatCreationFailed,
|
|
1272
1319
|
j as ChatMode,
|
|
1273
|
-
|
|
1274
|
-
|
|
1320
|
+
ve as ChatModeDowngraded,
|
|
1321
|
+
U as ChatProgress,
|
|
1275
1322
|
I as ConnectionState,
|
|
1276
1323
|
W as ConnectivityState,
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1324
|
+
ne as DataChannelSignalMap,
|
|
1325
|
+
Me as DocumentType,
|
|
1326
|
+
Se as KnowledgeType,
|
|
1327
|
+
De as PlanGroup,
|
|
1328
|
+
Te as Providers,
|
|
1329
|
+
_e as RateState,
|
|
1283
1330
|
Y as StreamEvents,
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1331
|
+
F as StreamType,
|
|
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,
|
|
1293
1340
|
pt as getAgent,
|
|
1294
|
-
|
|
1341
|
+
Ie as mapVideoType
|
|
1295
1342
|
};
|