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