@d-id/client-sdk 1.1.69-staging.331 → 1.1.69-staging.334
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var Z = (e, t, r) =>
|
|
1
|
+
var Xe = Object.defineProperty;
|
|
2
|
+
var Ge = (e, t, r) => t in e ? Xe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var Z = (e, t, r) => Ge(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
4
|
class de extends Error {
|
|
5
5
|
constructor({ kind: r, description: a, error: c }) {
|
|
6
6
|
super(JSON.stringify({ kind: r, description: a }));
|
|
@@ -18,25 +18,25 @@ class Ye extends de {
|
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
class
|
|
21
|
+
class Qe extends de {
|
|
22
22
|
constructor(t) {
|
|
23
23
|
super({ kind: "ChatModeDowngraded", description: `Chat mode downgraded to ${t}` });
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
class
|
|
26
|
+
class Y extends de {
|
|
27
27
|
constructor(r, a) {
|
|
28
28
|
super({ kind: "ValidationError", description: r });
|
|
29
29
|
Z(this, "key");
|
|
30
30
|
this.key = a;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
class
|
|
33
|
+
class Ze extends de {
|
|
34
34
|
constructor(t) {
|
|
35
35
|
super({ kind: "WSError", description: t });
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
var
|
|
39
|
-
const
|
|
38
|
+
var et = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(et || {}), tt = /* @__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))(tt || {}), rt = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(rt || {}), nt = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(nt || {}), A = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e.Off = "Off", e))(A || {}), B = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Transcribe = "transcribe", e.Complete = "done", e))(B || {}), at = /* @__PURE__ */ ((e) => (e.KnowledgeProcessing = "knowledge/processing", e.KnowledgeIndexing = "knowledge/indexing", e.KnowledgeFailed = "knowledge/error", e.KnowledgeDone = "knowledge/done", e))(at || {}), it = /* @__PURE__ */ ((e) => (e.Knowledge = "knowledge", e.Document = "document", e.Record = "record", e))(it || {}), st = /* @__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))(st || {}), ze = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e.Expressive = "expressive", e))(ze || {});
|
|
39
|
+
const lr = (e) => {
|
|
40
40
|
switch (e) {
|
|
41
41
|
case "clip":
|
|
42
42
|
return "clip";
|
|
@@ -48,9 +48,9 @@ const dr = (e) => {
|
|
|
48
48
|
throw new Error(`Unknown video type: ${e}`);
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
var S = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(S || {}), te = /* @__PURE__ */ ((e) => (e.Strong = "STRONG", e.Weak = "WEAK", e.Unknown = "UNKNOWN", e))(te || {}), ne = /* @__PURE__ */ ((e) => (e.Idle = "IDLE", e.Loading = "LOADING", e.Talking = "TALKING", e.ToolActive = "TOOL_ACTIVE", e))(ne || {}), x = /* @__PURE__ */ ((e) => (e.ChatAnswer = "chat/answer", e.ChatPartial = "chat/partial", e.ChatAudioTranscribed = "chat/audio-transcribed", e.StreamDone = "stream/done", e.StreamStarted = "stream/started", e.StreamFailed = "stream/error", e.StreamReady = "stream/ready", e.StreamCreated = "stream/created", e.StreamInterrupt = "stream/interrupt", e.StreamVideoCreated = "stream-video/started", e.StreamVideoDone = "stream-video/done", e.StreamVideoError = "stream-video/error", e.StreamVideoRejected = "stream-video/rejected", e.ToolCallStarted = "tool-call/started", e.ToolCallDone = "tool-call/done", e.ToolCallError = "tool-call/error", e))(x || {}),
|
|
52
|
-
const
|
|
53
|
-
},
|
|
51
|
+
var S = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(S || {}), te = /* @__PURE__ */ ((e) => (e.Strong = "STRONG", e.Weak = "WEAK", e.Unknown = "UNKNOWN", e))(te || {}), ne = /* @__PURE__ */ ((e) => (e.Idle = "IDLE", e.Loading = "LOADING", e.Talking = "TALKING", e.ToolActive = "TOOL_ACTIVE", e))(ne || {}), x = /* @__PURE__ */ ((e) => (e.ChatAnswer = "chat/answer", e.ChatPartial = "chat/partial", e.ChatAudioTranscribed = "chat/audio-transcribed", e.StreamDone = "stream/done", e.StreamStarted = "stream/started", e.StreamFailed = "stream/error", e.StreamReady = "stream/ready", e.StreamCreated = "stream/created", e.StreamInterrupt = "stream/interrupt", e.StreamVideoCreated = "stream-video/started", e.StreamVideoDone = "stream-video/done", e.StreamVideoError = "stream-video/error", e.StreamVideoRejected = "stream-video/rejected", e.ToolCallStarted = "tool-call/started", e.ToolCallDone = "tool-call/done", e.ToolCallError = "tool-call/error", e))(x || {}), b = /* @__PURE__ */ ((e) => (e.New = "new", e.Fail = "fail", e.Connected = "connected", e.Connecting = "connecting", e.Closed = "closed", e.Completed = "completed", e.Disconnecting = "disconnecting", e.Disconnected = "disconnected", e))(b || {}), W = /* @__PURE__ */ ((e) => (e.Legacy = "legacy", e.Fluent = "fluent", e))(W || {}), he = /* @__PURE__ */ ((e) => (e.Livekit = "livekit", e))(he || {}), ot = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.AzureOpenAi = "azure-openai", e.Microsoft = "microsoft", e.Afflorithmics = "afflorithmics", e.Elevenlabs = "elevenlabs", e))(ot || {}), ct = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e))(ct || {});
|
|
52
|
+
const ur = (...e) => {
|
|
53
|
+
}, Fe = (e) => new Promise((t) => setTimeout(t, e)), G = (e = 16) => {
|
|
54
54
|
const t = new Uint8Array(e);
|
|
55
55
|
return window.crypto.getRandomValues(t), Array.from(t, (r) => r.toString(16).padStart(2, "0")).join("").slice(0, 13);
|
|
56
56
|
};
|
|
@@ -59,25 +59,25 @@ function me(e) {
|
|
|
59
59
|
return window.localStorage.setItem("did_external_key_id", e), e;
|
|
60
60
|
let t = window.localStorage.getItem("did_external_key_id");
|
|
61
61
|
if (!t) {
|
|
62
|
-
let r =
|
|
62
|
+
let r = G();
|
|
63
63
|
window.localStorage.setItem("did_external_key_id", r), t = r;
|
|
64
64
|
}
|
|
65
65
|
return t;
|
|
66
66
|
}
|
|
67
|
-
let
|
|
68
|
-
function
|
|
69
|
-
|
|
67
|
+
let Ne = G();
|
|
68
|
+
function dt() {
|
|
69
|
+
Ne = G();
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function Ve(e, t) {
|
|
72
72
|
if (e.type === "bearer")
|
|
73
73
|
return `Bearer ${e.token}`;
|
|
74
74
|
if (e.type === "basic")
|
|
75
75
|
return `Basic ${"token" in e ? e.token : btoa(`${e.username}:${e.password}`)}`;
|
|
76
76
|
if (e.type === "key")
|
|
77
|
-
return `Client-Key ${e.clientKey}.${me(t)}_${
|
|
77
|
+
return `Client-Key ${e.clientKey}.${me(t)}_${Ne}`;
|
|
78
78
|
throw new Error(`Unknown auth type: ${e}`);
|
|
79
79
|
}
|
|
80
|
-
const
|
|
80
|
+
const lt = 45 * 1e3, ut = "X-Playground-Chat", ke = 2e3, le = "https://api.d-id.com", mt = "wss://notifications.d-id.com", ft = "79f81a83a67430be2bc0fd61042b8faa", Ke = (e) => e.type === "clip" && e.presenter_id.startsWith("v2_") ? "clip_v2" : e.type, gt = (e) => {
|
|
81
81
|
switch (e.type) {
|
|
82
82
|
case "expressive":
|
|
83
83
|
return "v4";
|
|
@@ -86,36 +86,36 @@ const dt = 45 * 1e3, lt = "X-Playground-Chat", le = "https://api.d-id.com", ut =
|
|
|
86
86
|
case "talk":
|
|
87
87
|
return "v2";
|
|
88
88
|
}
|
|
89
|
-
},
|
|
90
|
-
function
|
|
89
|
+
}, pt = (e) => e.type === "talk" ? e.source_url : e.presenter_id, we = (e) => e === ze.Expressive, ht = (e) => [A.TextOnly, A.Playground, A.Maintenance].includes(e), Ue = (e) => e && [A.DirectPlayback, A.Off].includes(e), Re = /\[!\[([^\[\]]*)\]\(([^)\s]+)\)\]\(([^)\s]+)\)/g, Ie = /!\[([^\[\]]*)\]\(([^)\s]+)\)/g, wt = [".mp4", ".webm", ".mkv", ".mov", ".m4v", ".ogv"];
|
|
90
|
+
function vt(e) {
|
|
91
91
|
const t = e.split("?")[0].split("#")[0].toLowerCase();
|
|
92
|
-
return
|
|
92
|
+
return wt.some((r) => t.endsWith(r));
|
|
93
93
|
}
|
|
94
|
-
const
|
|
95
|
-
function
|
|
94
|
+
const De = new RegExp("(?<!!)\\[([^\\[\\]]+)\\]\\(([^)\\s]+)\\)", "g"), Me = /<a\s+href="([^"]*)"[^>]*?>([^<]*)<\/a>/gi;
|
|
95
|
+
function yt(e) {
|
|
96
96
|
if (e.length === 0)
|
|
97
97
|
return [];
|
|
98
98
|
const t = [];
|
|
99
99
|
let r;
|
|
100
|
-
for (
|
|
100
|
+
for (Re.lastIndex = 0; (r = Re.exec(e)) !== null; )
|
|
101
101
|
t.push({
|
|
102
102
|
index: r.index,
|
|
103
103
|
length: r[0].length,
|
|
104
104
|
part: { type: "video", src: r[3], alt: r[1], thumbnail: r[2] }
|
|
105
105
|
});
|
|
106
|
-
for (
|
|
106
|
+
for (Ie.lastIndex = 0; (r = Ie.exec(e)) !== null; )
|
|
107
107
|
if (!t.some((o) => r.index >= o.index && r.index < o.index + o.length)) {
|
|
108
108
|
const o = r[2], n = r[1];
|
|
109
109
|
let i;
|
|
110
|
-
|
|
110
|
+
vt(o) ? i = { type: "video", src: o, alt: n } : (i = { type: "image", src: o, alt: n }, o.toLowerCase().endsWith(".gif") && (i.mimeType = "image/gif")), t.push({ index: r.index, length: r[0].length, part: i });
|
|
111
111
|
}
|
|
112
|
-
for (
|
|
112
|
+
for (De.lastIndex = 0; (r = De.exec(e)) !== null; )
|
|
113
113
|
t.some((o) => r.index >= o.index && r.index < o.index + o.length) || t.push({
|
|
114
114
|
index: r.index,
|
|
115
115
|
length: r[0].length,
|
|
116
116
|
part: { type: "link", href: r[2], label: r[1] }
|
|
117
117
|
});
|
|
118
|
-
for (
|
|
118
|
+
for (Me.lastIndex = 0; (r = Me.exec(e)) !== null; )
|
|
119
119
|
t.some((o) => r.index >= o.index && r.index < o.index + o.length) || t.push({
|
|
120
120
|
index: r.index,
|
|
121
121
|
length: r[0].length,
|
|
@@ -130,11 +130,11 @@ function vt(e) {
|
|
|
130
130
|
s.index > c && a.push({ type: "text", text: e.slice(c, s.index) }), a.push(s.part), c = s.index + s.length;
|
|
131
131
|
return c < e.length && a.push({ type: "text", text: e.slice(c) }), a;
|
|
132
132
|
}
|
|
133
|
-
let
|
|
133
|
+
let Ee = "", ue = [];
|
|
134
134
|
function re(e) {
|
|
135
|
-
return e ===
|
|
135
|
+
return e === Ee || (Ee = e, ue = yt(e)), ue;
|
|
136
136
|
}
|
|
137
|
-
function
|
|
137
|
+
function Ct(e, t) {
|
|
138
138
|
let r;
|
|
139
139
|
return {
|
|
140
140
|
promise: new Promise((c, s) => {
|
|
@@ -158,32 +158,32 @@ async function fe(e, t) {
|
|
|
158
158
|
try {
|
|
159
159
|
if (!r.timeout)
|
|
160
160
|
return await e();
|
|
161
|
-
const { promise: s, clear: o } =
|
|
161
|
+
const { promise: s, clear: o } = Ct(r.timeout, r.timeoutErrorMessage), n = e().finally(o);
|
|
162
162
|
return await Promise.race([n, s]);
|
|
163
163
|
} catch (s) {
|
|
164
164
|
if (a = s, !r.shouldRetryFn(s) || c >= r.limit)
|
|
165
165
|
throw s;
|
|
166
|
-
await
|
|
166
|
+
await Fe(r.delayMs), r.onRetry(s);
|
|
167
167
|
}
|
|
168
168
|
throw a;
|
|
169
169
|
}
|
|
170
|
-
const
|
|
170
|
+
const St = (e) => fe(e, {
|
|
171
171
|
limit: 3,
|
|
172
172
|
delayMs: 1e3,
|
|
173
173
|
timeout: 0,
|
|
174
174
|
shouldRetryFn: (t) => t.status === 429
|
|
175
175
|
});
|
|
176
|
-
function
|
|
176
|
+
function We(e, t = le, r, a) {
|
|
177
177
|
const c = async (s, o) => {
|
|
178
178
|
const { skipErrorHandler: n, ...i } = o || {};
|
|
179
179
|
let d;
|
|
180
180
|
try {
|
|
181
|
-
d = await
|
|
181
|
+
d = await St(
|
|
182
182
|
() => fetch(t + (s != null && s.startsWith("/") ? s : `/${s}`), {
|
|
183
183
|
...i,
|
|
184
184
|
headers: {
|
|
185
185
|
...i.headers,
|
|
186
|
-
Authorization:
|
|
186
|
+
Authorization: Ve(e, a),
|
|
187
187
|
"Content-Type": "application/json"
|
|
188
188
|
}
|
|
189
189
|
})
|
|
@@ -213,8 +213,8 @@ function Ue(e, t = le, r, a) {
|
|
|
213
213
|
}
|
|
214
214
|
};
|
|
215
215
|
}
|
|
216
|
-
function
|
|
217
|
-
const c =
|
|
216
|
+
function kt(e, t = le, r, a) {
|
|
217
|
+
const c = We(e, `${t}/agents`, r, a);
|
|
218
218
|
return {
|
|
219
219
|
create(s, o) {
|
|
220
220
|
return c.post("/", s, o);
|
|
@@ -251,7 +251,7 @@ function St(e, t = le, r, a) {
|
|
|
251
251
|
}
|
|
252
252
|
};
|
|
253
253
|
}
|
|
254
|
-
function
|
|
254
|
+
function Rt(e) {
|
|
255
255
|
var c, s, o, n;
|
|
256
256
|
const t = () => /Mobi|Android/i.test(navigator.userAgent) ? "Mobile" : "Desktop", r = () => {
|
|
257
257
|
const i = navigator.platform;
|
|
@@ -262,20 +262,20 @@ function kt(e) {
|
|
|
262
262
|
isMobile: `${t() == "Mobile"}`,
|
|
263
263
|
browser: navigator.userAgent,
|
|
264
264
|
origin: window.location.origin,
|
|
265
|
-
agentType:
|
|
265
|
+
agentType: Ke(a),
|
|
266
266
|
agentVoice: {
|
|
267
267
|
voiceId: (s = (c = e.presenter) == null ? void 0 : c.voice) == null ? void 0 : s.voice_id,
|
|
268
268
|
provider: (n = (o = e.presenter) == null ? void 0 : o.voice) == null ? void 0 : n.type
|
|
269
269
|
}
|
|
270
270
|
};
|
|
271
271
|
}
|
|
272
|
-
function
|
|
272
|
+
function It(e) {
|
|
273
273
|
var r, a, c, s, o, n;
|
|
274
274
|
const t = (r = e.llm) == null ? void 0 : r.prompt_customization;
|
|
275
275
|
return {
|
|
276
|
-
agentType:
|
|
277
|
-
presenterType:
|
|
278
|
-
presenter:
|
|
276
|
+
agentType: Ke(e.presenter),
|
|
277
|
+
presenterType: gt(e.presenter),
|
|
278
|
+
presenter: pt(e.presenter),
|
|
279
279
|
owner_id: e.owner_id ?? "",
|
|
280
280
|
promptVersion: (a = e.llm) == null ? void 0 : a.prompt_version,
|
|
281
281
|
behavior: {
|
|
@@ -294,14 +294,14 @@ function Rt(e) {
|
|
|
294
294
|
...e.access === "public" ? { from: "agent-template" } : {}
|
|
295
295
|
};
|
|
296
296
|
}
|
|
297
|
-
const
|
|
297
|
+
const _e = (e) => {
|
|
298
298
|
try {
|
|
299
299
|
return String((e == null ? void 0 : e.message) ?? e ?? "").slice(0, 256);
|
|
300
300
|
} catch {
|
|
301
301
|
return "Unknown error";
|
|
302
302
|
}
|
|
303
|
-
},
|
|
304
|
-
function
|
|
303
|
+
}, Dt = (e) => e.reduce((t, r) => t + r, 0), Te = (e) => Dt(e) / e.length;
|
|
304
|
+
function Mt(e, t, r) {
|
|
305
305
|
var i, d, u;
|
|
306
306
|
const { event: a, ...c } = e, { template: s } = (t == null ? void 0 : t.llm) || {}, { language: o } = ((i = t == null ? void 0 : t.presenter) == null ? void 0 : i.voice) || {};
|
|
307
307
|
return {
|
|
@@ -312,11 +312,11 @@ function Dt(e, t, r) {
|
|
|
312
312
|
...r
|
|
313
313
|
};
|
|
314
314
|
}
|
|
315
|
-
function
|
|
315
|
+
function Ae(e) {
|
|
316
316
|
"requestIdleCallback" in window ? requestIdleCallback(e, { timeout: 2e3 }) : setTimeout(e, 0);
|
|
317
317
|
}
|
|
318
|
-
const
|
|
319
|
-
function
|
|
318
|
+
const Et = "https://api-js.mixpanel.com/track/?verbose=1&ip=1";
|
|
319
|
+
function _t(e) {
|
|
320
320
|
const t = window != null && window.hasOwnProperty("DID_AGENTS_API") ? "agents-ui" : "agents-sdk", r = {};
|
|
321
321
|
return {
|
|
322
322
|
token: e.token || "testKey",
|
|
@@ -327,7 +327,7 @@ function Et(e) {
|
|
|
327
327
|
...e.mixpanelAdditionalProperties || {}
|
|
328
328
|
},
|
|
329
329
|
isEnabled: e.isEnabled ?? !0,
|
|
330
|
-
getRandom:
|
|
330
|
+
getRandom: G,
|
|
331
331
|
enrich(a) {
|
|
332
332
|
this.additionalProperties = { ...this.additionalProperties, ...a };
|
|
333
333
|
},
|
|
@@ -360,7 +360,7 @@ function Et(e) {
|
|
|
360
360
|
])
|
|
361
361
|
})
|
|
362
362
|
};
|
|
363
|
-
return fetch(
|
|
363
|
+
return fetch(Et, d).catch((u) => console.error("Analytics tracking error:", u)), Promise.resolve();
|
|
364
364
|
},
|
|
365
365
|
linkTrack(a, c, s, o) {
|
|
366
366
|
r[a] || (r[a] = { events: {}, resolvedDependencies: [] }), o.includes(s) || o.push(s);
|
|
@@ -387,21 +387,21 @@ function ve() {
|
|
|
387
387
|
};
|
|
388
388
|
}
|
|
389
389
|
const H = ve(), ge = ve(), be = ve();
|
|
390
|
-
function
|
|
391
|
-
return e ===
|
|
390
|
+
function Je(e) {
|
|
391
|
+
return e === A.Playground ? { headers: { [ut]: "true" } } : {};
|
|
392
392
|
}
|
|
393
|
-
async function
|
|
393
|
+
async function Oe(e, t, r, a, c = !1, s) {
|
|
394
394
|
try {
|
|
395
|
-
return !s && !
|
|
395
|
+
return !s && !Ue(a) && (s = await t.newChat(e.id, { persist: c }, Je(a)), r.track("agent-chat", {
|
|
396
396
|
event: "created",
|
|
397
397
|
chatId: s.id,
|
|
398
398
|
mode: a
|
|
399
399
|
})), { chat: s, chatMode: (s == null ? void 0 : s.chat_mode) ?? a };
|
|
400
400
|
} catch (o) {
|
|
401
|
-
throw
|
|
401
|
+
throw Tt(o) === "InsufficientCreditsError" ? new Error("InsufficientCreditsError") : new Error("Cannot create new chat");
|
|
402
402
|
}
|
|
403
403
|
}
|
|
404
|
-
const
|
|
404
|
+
const Tt = (e) => {
|
|
405
405
|
try {
|
|
406
406
|
const t = JSON.parse(e.message);
|
|
407
407
|
return t == null ? void 0 : t.kind;
|
|
@@ -409,12 +409,12 @@ const _t = (e) => {
|
|
|
409
409
|
return "UnknownError";
|
|
410
410
|
}
|
|
411
411
|
};
|
|
412
|
-
function
|
|
412
|
+
function At(e) {
|
|
413
413
|
return e && e.length > 0 ? e : [];
|
|
414
414
|
}
|
|
415
415
|
function bt(e) {
|
|
416
416
|
return new Promise((t, r) => {
|
|
417
|
-
const { callbacks: a, host: c, auth: s, externalId: o } = e, { onMessage: n = null, onOpen: i = null, onClose: d = null, onError: u = null } = a || {}, m = new WebSocket(`${c}?authorization=${encodeURIComponent(
|
|
417
|
+
const { callbacks: a, host: c, auth: s, externalId: o } = e, { onMessage: n = null, onOpen: i = null, onClose: d = null, onError: u = null } = a || {}, m = new WebSocket(`${c}?authorization=${encodeURIComponent(Ve(s, o))}`);
|
|
418
418
|
m.onmessage = n, m.onclose = d, m.onerror = (f) => {
|
|
419
419
|
console.error(f), u == null || u("Websocket failed to connect", f), r(f);
|
|
420
420
|
}, m.onopen = (f) => {
|
|
@@ -422,7 +422,7 @@ function bt(e) {
|
|
|
422
422
|
};
|
|
423
423
|
});
|
|
424
424
|
}
|
|
425
|
-
async function
|
|
425
|
+
async function xt(e) {
|
|
426
426
|
const { retries: t = 1 } = e;
|
|
427
427
|
let r = null;
|
|
428
428
|
for (let a = 0; (r == null ? void 0 : r.readyState) !== WebSocket.OPEN; a++)
|
|
@@ -431,19 +431,19 @@ async function At(e) {
|
|
|
431
431
|
} catch (c) {
|
|
432
432
|
if (a === t)
|
|
433
433
|
throw c;
|
|
434
|
-
await
|
|
434
|
+
await Fe(a * 500);
|
|
435
435
|
}
|
|
436
436
|
return r;
|
|
437
437
|
}
|
|
438
|
-
async function
|
|
439
|
-
const c = r != null && r.onMessage ? [r.onMessage] : [], s = await
|
|
438
|
+
async function Lt(e, t, r, a) {
|
|
439
|
+
const c = r != null && r.onMessage ? [r.onMessage] : [], s = await xt({
|
|
440
440
|
auth: e,
|
|
441
441
|
host: t,
|
|
442
442
|
externalId: a,
|
|
443
443
|
callbacks: {
|
|
444
444
|
onError: (o) => {
|
|
445
445
|
var n;
|
|
446
|
-
return (n = r.onError) == null ? void 0 : n.call(r, new
|
|
446
|
+
return (n = r.onError) == null ? void 0 : n.call(r, new Ze(o));
|
|
447
447
|
},
|
|
448
448
|
onMessage(o) {
|
|
449
449
|
const n = JSON.parse(o.data);
|
|
@@ -457,7 +457,7 @@ async function xt(e, t, r, a) {
|
|
|
457
457
|
subscribeToEvents: (o) => c.push(o)
|
|
458
458
|
};
|
|
459
459
|
}
|
|
460
|
-
function
|
|
460
|
+
function xe(e) {
|
|
461
461
|
if (e.answer !== void 0)
|
|
462
462
|
return e.answer;
|
|
463
463
|
let t = 0, r = "";
|
|
@@ -465,7 +465,7 @@ function Ae(e) {
|
|
|
465
465
|
r += e[t++];
|
|
466
466
|
return r;
|
|
467
467
|
}
|
|
468
|
-
function
|
|
468
|
+
function Pt(e, t, r) {
|
|
469
469
|
if (!e.content)
|
|
470
470
|
return;
|
|
471
471
|
const a = {
|
|
@@ -478,15 +478,15 @@ function Lt(e, t, r) {
|
|
|
478
478
|
};
|
|
479
479
|
t.messages.push(a), r == null || r([...t.messages], "user");
|
|
480
480
|
}
|
|
481
|
-
function
|
|
482
|
-
if (e ===
|
|
483
|
-
|
|
481
|
+
function jt(e, t, r, a, c, s, o) {
|
|
482
|
+
if (e === B.Transcribe && t.content) {
|
|
483
|
+
Pt(t, a, c);
|
|
484
484
|
return;
|
|
485
485
|
}
|
|
486
|
-
if (!(e ===
|
|
486
|
+
if (!(e === B.Partial || e === B.Answer))
|
|
487
487
|
return;
|
|
488
488
|
const n = a.messages[a.messages.length - 1];
|
|
489
|
-
if (e ===
|
|
489
|
+
if (e === B.Answer && (n == null ? void 0 : n.role) === "user" && o === "partial")
|
|
490
490
|
return;
|
|
491
491
|
const d = o === "answer";
|
|
492
492
|
let u;
|
|
@@ -503,16 +503,16 @@ function Pt(e, t, r, a, c, s, o) {
|
|
|
503
503
|
else
|
|
504
504
|
return;
|
|
505
505
|
const { content: m, sequence: f } = t;
|
|
506
|
-
if (e ===
|
|
506
|
+
if (e === B.Partial)
|
|
507
507
|
r[f] = m;
|
|
508
508
|
else {
|
|
509
|
-
const y =
|
|
509
|
+
const y = xe(r);
|
|
510
510
|
!!(m && m.length < y.length) && (u.interrupted = !0), r.answer = m;
|
|
511
511
|
}
|
|
512
|
-
const w =
|
|
513
|
-
(u.content !== w || e ===
|
|
512
|
+
const w = xe(r);
|
|
513
|
+
(u.content !== w || e === B.Answer) && (u.content = w, u.parts = re(w), c == null || c([...a.messages], e));
|
|
514
514
|
}
|
|
515
|
-
function
|
|
515
|
+
function $t(e, t, r, a, c) {
|
|
516
516
|
const s = {}, o = () => {
|
|
517
517
|
for (const d of Object.keys(s))
|
|
518
518
|
delete s[d];
|
|
@@ -527,8 +527,8 @@ function jt(e, t, r, a, c) {
|
|
|
527
527
|
onMessage: (d, u) => {
|
|
528
528
|
var m, f;
|
|
529
529
|
if ("content" in u) {
|
|
530
|
-
const w = d === x.ChatAnswer ?
|
|
531
|
-
|
|
530
|
+
const w = d === x.ChatAnswer ? B.Answer : d === x.ChatAudioTranscribed ? B.Transcribe : d;
|
|
531
|
+
jt(
|
|
532
532
|
w,
|
|
533
533
|
u,
|
|
534
534
|
s,
|
|
@@ -536,13 +536,13 @@ function jt(e, t, r, a, c) {
|
|
|
536
536
|
i,
|
|
537
537
|
o,
|
|
538
538
|
n
|
|
539
|
-
), w ===
|
|
539
|
+
), w === B.Partial ? n = "partial" : w === B.Answer && (n = "answer", o()), w === B.Answer && e.track("agent-message-received", {
|
|
540
540
|
content: u.content,
|
|
541
541
|
messages: t.messages.length,
|
|
542
542
|
mode: t.chatMode
|
|
543
543
|
});
|
|
544
544
|
} else {
|
|
545
|
-
const w = x, y = [w.StreamVideoDone, w.StreamVideoError, w.StreamVideoRejected], j = [w.StreamFailed, w.StreamVideoError, w.StreamVideoRejected], M =
|
|
545
|
+
const w = x, y = [w.StreamVideoDone, w.StreamVideoError, w.StreamVideoRejected], j = [w.StreamFailed, w.StreamVideoError, w.StreamVideoRejected], M = Mt(u, a, { mode: t.chatMode });
|
|
546
546
|
if (d = d, d === w.StreamVideoCreated && (e.linkTrack("agent-video", M, w.StreamVideoCreated, ["start"]), u.sentiment)) {
|
|
547
547
|
const _ = t.messages[t.messages.length - 1];
|
|
548
548
|
if ((_ == null ? void 0 : _.role) === "assistant") {
|
|
@@ -560,7 +560,7 @@ function jt(e, t, r, a, c) {
|
|
|
560
560
|
};
|
|
561
561
|
}
|
|
562
562
|
function Bt(e, t, r, a) {
|
|
563
|
-
const c =
|
|
563
|
+
const c = We(e, `${t}/agents/${r}`, a);
|
|
564
564
|
return {
|
|
565
565
|
createStream(s, o) {
|
|
566
566
|
return c.post("/streams", s, { signal: o });
|
|
@@ -596,8 +596,8 @@ function Bt(e, t, r, a) {
|
|
|
596
596
|
}
|
|
597
597
|
};
|
|
598
598
|
}
|
|
599
|
-
const
|
|
600
|
-
function
|
|
599
|
+
const zt = (e, t) => (r, a) => e && console.log(`[${t}] ${r}`, a ?? "");
|
|
600
|
+
function Ft(e, t, r) {
|
|
601
601
|
const a = (t.timestamp - e.timestamp) / 1e3;
|
|
602
602
|
return {
|
|
603
603
|
duration: a,
|
|
@@ -617,7 +617,7 @@ function zt(e, t, r) {
|
|
|
617
617
|
lowFpsCount: r
|
|
618
618
|
};
|
|
619
619
|
}
|
|
620
|
-
function
|
|
620
|
+
function Nt(e) {
|
|
621
621
|
return e.filter(
|
|
622
622
|
(t) => t.freezeCount > 0 || t.framesPerSecond < 21 || t.framesDropped > 0 || t.packetsLost > 0
|
|
623
623
|
).map((t) => {
|
|
@@ -628,7 +628,7 @@ function Ft(e) {
|
|
|
628
628
|
};
|
|
629
629
|
});
|
|
630
630
|
}
|
|
631
|
-
function
|
|
631
|
+
function Vt(e) {
|
|
632
632
|
var o;
|
|
633
633
|
let t = "", r = 0, a = null;
|
|
634
634
|
const c = /* @__PURE__ */ new Map();
|
|
@@ -663,7 +663,7 @@ function Nt(e) {
|
|
|
663
663
|
freezeDuration: s.totalFreezesDuration
|
|
664
664
|
};
|
|
665
665
|
}
|
|
666
|
-
function
|
|
666
|
+
function Le(e, t, r) {
|
|
667
667
|
const a = e.map((i, d) => d === 0 ? r ? {
|
|
668
668
|
timestamp: i.timestamp,
|
|
669
669
|
duration: 0,
|
|
@@ -715,30 +715,30 @@ function xe(e, t, r) {
|
|
|
715
715
|
framesPerSecond: i.framesPerSecond,
|
|
716
716
|
freezeCount: i.freezeCount - e[d - 1].freezeCount,
|
|
717
717
|
freezeDuration: i.freezeDuration - e[d - 1].freezeDuration
|
|
718
|
-
}), c =
|
|
718
|
+
}), c = Nt(a), s = c.reduce((i, d) => i + (d.causes.includes("low fps") ? 1 : 0), 0), o = a.filter((i) => !!i.avgJitterDelayInInterval).map((i) => i.avgJitterDelayInInterval), n = a.filter((i) => !!i.rtt).map((i) => i.rtt);
|
|
719
719
|
return {
|
|
720
720
|
webRTCStats: {
|
|
721
721
|
anomalies: c,
|
|
722
722
|
minRtt: Math.min(...n),
|
|
723
|
-
avgRtt:
|
|
723
|
+
avgRtt: Te(n),
|
|
724
724
|
maxRtt: Math.max(...n),
|
|
725
|
-
aggregateReport:
|
|
725
|
+
aggregateReport: Ft(e[0], e[e.length - 1], s),
|
|
726
726
|
minJitterDelayInInterval: Math.min(...o),
|
|
727
727
|
maxJitterDelayInInterval: Math.max(...o),
|
|
728
|
-
avgJitterDelayInInterval:
|
|
728
|
+
avgJitterDelayInInterval: Te(o)
|
|
729
729
|
},
|
|
730
730
|
codec: e[0].codec,
|
|
731
731
|
resolution: `${e[0].frameWidth}x${e[0].frameHeight}`
|
|
732
732
|
};
|
|
733
733
|
}
|
|
734
|
-
function
|
|
734
|
+
function He(e, t) {
|
|
735
735
|
for (const r of e.values())
|
|
736
736
|
if ((r == null ? void 0 : r.type) === "inbound-rtp" && r.kind === t)
|
|
737
737
|
return r;
|
|
738
738
|
return null;
|
|
739
739
|
}
|
|
740
740
|
const ee = 10;
|
|
741
|
-
function
|
|
741
|
+
function mr(e, t) {
|
|
742
742
|
let r = !1, a = !1, c = null, s = 0, o = 0, n = {};
|
|
743
743
|
async function i() {
|
|
744
744
|
if (r) {
|
|
@@ -748,7 +748,7 @@ function ur(e, t) {
|
|
|
748
748
|
c = setTimeout(i, ee);
|
|
749
749
|
return;
|
|
750
750
|
}
|
|
751
|
-
const u =
|
|
751
|
+
const u = He(d, "audio");
|
|
752
752
|
if (!u) {
|
|
753
753
|
c = setTimeout(i, ee);
|
|
754
754
|
return;
|
|
@@ -777,11 +777,11 @@ function ur(e, t) {
|
|
|
777
777
|
}
|
|
778
778
|
};
|
|
779
779
|
}
|
|
780
|
-
const ce = 100,
|
|
781
|
-
function
|
|
780
|
+
const ce = 100, Kt = Math.max(Math.ceil(400 / ce), 1), Ut = 0.25, Wt = 0.28;
|
|
781
|
+
function Jt() {
|
|
782
782
|
let e = 0, t, r, a = 0;
|
|
783
783
|
return (c) => {
|
|
784
|
-
const s =
|
|
784
|
+
const s = He(c, "video");
|
|
785
785
|
if (!s)
|
|
786
786
|
return { isReceiving: !1, avgJitterDelayInInterval: a };
|
|
787
787
|
const o = s.jitterBufferDelay, n = s.jitterBufferEmittedCount;
|
|
@@ -794,18 +794,18 @@ function Wt() {
|
|
|
794
794
|
return e = i, { isReceiving: d, avgJitterDelayInInterval: a, freezeCount: s.freezeCount };
|
|
795
795
|
};
|
|
796
796
|
}
|
|
797
|
-
function
|
|
797
|
+
function Ot(e, t, r, a, c) {
|
|
798
798
|
let s = null, o = [], n, i = 0, d = !1, u = te.Unknown, m = te.Unknown, f = 0, w = 0;
|
|
799
|
-
const y =
|
|
799
|
+
const y = Jt();
|
|
800
800
|
async function j() {
|
|
801
801
|
const M = await e();
|
|
802
802
|
if (!M)
|
|
803
803
|
return;
|
|
804
|
-
const { isReceiving: _, avgJitterDelayInInterval: L, freezeCount: E } = y(M), q =
|
|
804
|
+
const { isReceiving: _, avgJitterDelayInInterval: L, freezeCount: E } = y(M), q = Vt(M);
|
|
805
805
|
if (_)
|
|
806
|
-
i = 0, f = E - w, m = L <
|
|
807
|
-
else if (d && (i++, i >=
|
|
808
|
-
const J =
|
|
806
|
+
i = 0, f = E - w, m = L < Ut ? te.Strong : L > Wt && f > 1 ? te.Weak : u, m !== u && (c == null || c(m), u = m, w += f, f = 0), d || (a == null || a(S.Start), n = o[o.length - 1], o = [], d = !0), o.push(q);
|
|
807
|
+
else if (d && (i++, i >= Kt)) {
|
|
808
|
+
const J = Le(o, ce, n);
|
|
809
809
|
a == null || a(S.Stop, J), t() || r(), w = E, d = !1;
|
|
810
810
|
}
|
|
811
811
|
}
|
|
@@ -816,31 +816,31 @@ function Jt(e, t, r, a, c) {
|
|
|
816
816
|
stop: () => {
|
|
817
817
|
s && (clearInterval(s), s = null);
|
|
818
818
|
},
|
|
819
|
-
getReport: () =>
|
|
819
|
+
getReport: () => Le(o, ce, n)
|
|
820
820
|
};
|
|
821
821
|
}
|
|
822
|
-
const
|
|
823
|
-
function
|
|
822
|
+
const Ht = (window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection).bind(window);
|
|
823
|
+
function Pe(e) {
|
|
824
824
|
switch (e) {
|
|
825
825
|
case "connected":
|
|
826
|
-
return
|
|
826
|
+
return b.Connected;
|
|
827
827
|
case "checking":
|
|
828
|
-
return
|
|
828
|
+
return b.Connecting;
|
|
829
829
|
case "failed":
|
|
830
|
-
return
|
|
830
|
+
return b.Fail;
|
|
831
831
|
case "new":
|
|
832
|
-
return
|
|
832
|
+
return b.New;
|
|
833
833
|
case "closed":
|
|
834
|
-
return
|
|
834
|
+
return b.Closed;
|
|
835
835
|
case "disconnected":
|
|
836
|
-
return
|
|
836
|
+
return b.Disconnected;
|
|
837
837
|
case "completed":
|
|
838
|
-
return
|
|
838
|
+
return b.Completed;
|
|
839
839
|
default:
|
|
840
|
-
return
|
|
840
|
+
return b.New;
|
|
841
841
|
}
|
|
842
842
|
}
|
|
843
|
-
const
|
|
843
|
+
const qt = (e) => (t) => {
|
|
844
844
|
const [r, a = ""] = t.split(/:(.+)/);
|
|
845
845
|
try {
|
|
846
846
|
const c = JSON.parse(a);
|
|
@@ -849,7 +849,7 @@ const Ht = (e) => (t) => {
|
|
|
849
849
|
return e("Failed to parse data channel message, returning data as string", { subject: r, rawData: a, error: c }), { subject: r, data: a };
|
|
850
850
|
}
|
|
851
851
|
};
|
|
852
|
-
function
|
|
852
|
+
function Xt({
|
|
853
853
|
statsSignal: e,
|
|
854
854
|
dataChannelSignal: t,
|
|
855
855
|
onVideoStateChange: r,
|
|
@@ -858,7 +858,7 @@ function qt({
|
|
|
858
858
|
}) {
|
|
859
859
|
e === S.Start && t === S.Start ? (c("CALLBACK: onVideoStateChange(Start)"), r == null || r(S.Start)) : e === S.Stop && t === S.Stop && (c("CALLBACK: onVideoStateChange(Stop)"), r == null || r(S.Stop, a));
|
|
860
860
|
}
|
|
861
|
-
function
|
|
861
|
+
function Gt({
|
|
862
862
|
statsSignal: e,
|
|
863
863
|
dataChannelSignal: t,
|
|
864
864
|
onVideoStateChange: r,
|
|
@@ -868,7 +868,7 @@ function Xt({
|
|
|
868
868
|
}) {
|
|
869
869
|
e === S.Start ? (s("CALLBACK: onVideoStateChange(Start)"), r == null || r(S.Start)) : e === S.Stop && (s("CALLBACK: onVideoStateChange(Stop)"), r == null || r(S.Stop, c)), t === S.Start ? a == null || a(ne.Talking) : t === S.Stop && (a == null || a(ne.Idle));
|
|
870
870
|
}
|
|
871
|
-
function
|
|
871
|
+
function je({
|
|
872
872
|
statsSignal: e,
|
|
873
873
|
dataChannelSignal: t,
|
|
874
874
|
onVideoStateChange: r,
|
|
@@ -877,7 +877,7 @@ function Pe({
|
|
|
877
877
|
report: s,
|
|
878
878
|
log: o
|
|
879
879
|
}) {
|
|
880
|
-
c === W.Legacy ?
|
|
880
|
+
c === W.Legacy ? Xt({ statsSignal: e, dataChannelSignal: t, onVideoStateChange: r, report: s, log: o }) : c === W.Fluent && Gt({
|
|
881
881
|
statsSignal: e,
|
|
882
882
|
dataChannelSignal: t,
|
|
883
883
|
onVideoStateChange: r,
|
|
@@ -888,7 +888,7 @@ function Pe({
|
|
|
888
888
|
}
|
|
889
889
|
async function Yt(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le, analytics: o }, n) {
|
|
890
890
|
var F;
|
|
891
|
-
const i =
|
|
891
|
+
const i = zt(r, "WebRTCStreamingManager"), d = qt(i);
|
|
892
892
|
let u = !1, m = !1, f = S.Stop, w = S.Stop;
|
|
893
893
|
const { startConnection: y, sendStreamRequest: j, close: M, createStream: _, addIceCandidate: L } = Bt(
|
|
894
894
|
c,
|
|
@@ -904,7 +904,7 @@ async function Yt(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le,
|
|
|
904
904
|
interrupt_enabled: X
|
|
905
905
|
} = await _(t, n);
|
|
906
906
|
(F = a.onStreamCreated) == null || F.call(a, { stream_id: E, session_id: N, agent_id: e });
|
|
907
|
-
const I = new
|
|
907
|
+
const I = new Ht({ iceServers: J }), O = I.createDataChannel("JanusDataChannel");
|
|
908
908
|
if (!N)
|
|
909
909
|
throw new Error("Could not create session_id");
|
|
910
910
|
const V = ae ? W.Fluent : W.Legacy;
|
|
@@ -913,12 +913,12 @@ async function Yt(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le,
|
|
|
913
913
|
});
|
|
914
914
|
const ie = t.stream_warmup && !ae, se = () => u, Q = () => {
|
|
915
915
|
var g;
|
|
916
|
-
u = !0, m && (i("CALLBACK: onConnectionStateChange(Connected)"), (g = a.onConnectionStateChange) == null || g.call(a,
|
|
917
|
-
}, l =
|
|
916
|
+
u = !0, m && (i("CALLBACK: onConnectionStateChange(Connected)"), (g = a.onConnectionStateChange) == null || g.call(a, b.Connected));
|
|
917
|
+
}, l = Ot(
|
|
918
918
|
() => I.getStats(),
|
|
919
919
|
se,
|
|
920
920
|
Q,
|
|
921
|
-
(g, p) =>
|
|
921
|
+
(g, p) => je({
|
|
922
922
|
statsSignal: w = g,
|
|
923
923
|
dataChannelSignal: V === W.Legacy ? f : void 0,
|
|
924
924
|
onVideoStateChange: a.onVideoStateChange,
|
|
@@ -962,7 +962,7 @@ async function Yt(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le,
|
|
|
962
962
|
const D = p.metadata;
|
|
963
963
|
v(D.videoId);
|
|
964
964
|
}
|
|
965
|
-
g === x.StreamDone && v(null), f = g === x.StreamStarted ? S.Start : S.Stop,
|
|
965
|
+
g === x.StreamDone && v(null), f = g === x.StreamStarted ? S.Start : S.Stop, je({
|
|
966
966
|
statsSignal: V === W.Legacy ? w : void 0,
|
|
967
967
|
dataChannelSignal: f,
|
|
968
968
|
onVideoStateChange: a.onVideoStateChange,
|
|
@@ -972,9 +972,9 @@ async function Yt(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le,
|
|
|
972
972
|
});
|
|
973
973
|
}
|
|
974
974
|
function k(g, p) {
|
|
975
|
-
var
|
|
975
|
+
var $;
|
|
976
976
|
const D = typeof p == "string" ? p : p == null ? void 0 : p.metadata;
|
|
977
|
-
D && o.enrich({ streamMetadata: D }), (
|
|
977
|
+
D && o.enrich({ streamMetadata: D }), ($ = a.onStreamReady) == null || $.call(a);
|
|
978
978
|
}
|
|
979
979
|
const R = {
|
|
980
980
|
[x.StreamStarted]: C,
|
|
@@ -982,14 +982,14 @@ async function Yt(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le,
|
|
|
982
982
|
[x.StreamReady]: k
|
|
983
983
|
};
|
|
984
984
|
O.onmessage = (g) => {
|
|
985
|
-
var
|
|
985
|
+
var $;
|
|
986
986
|
const { subject: p, data: D } = d(g.data);
|
|
987
|
-
(
|
|
987
|
+
($ = R[p]) == null || $.call(R, p, D);
|
|
988
988
|
}, I.oniceconnectionstatechange = () => {
|
|
989
989
|
var p;
|
|
990
990
|
i("peerConnection.oniceconnectionstatechange => " + I.iceConnectionState);
|
|
991
|
-
const g =
|
|
992
|
-
g !==
|
|
991
|
+
const g = Pe(I.iceConnectionState);
|
|
992
|
+
g !== b.Connected && ((p = a.onConnectionStateChange) == null || p.call(a, g));
|
|
993
993
|
}, I.ontrack = (g) => {
|
|
994
994
|
var p;
|
|
995
995
|
i("peerConnection.ontrack", g), i("CALLBACK: onSrcObjectReady"), (p = a.onSrcObjectReady) == null || p.call(a, g.streams[0]);
|
|
@@ -1006,8 +1006,8 @@ async function Yt(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le,
|
|
|
1006
1006
|
}
|
|
1007
1007
|
try {
|
|
1008
1008
|
O.send(g);
|
|
1009
|
-
} catch (
|
|
1010
|
-
i("Error sending data channel message",
|
|
1009
|
+
} catch ($) {
|
|
1010
|
+
i("Error sending data channel message", $), (D = a.onError) == null || D.call(a, $, { streamId: E });
|
|
1011
1011
|
}
|
|
1012
1012
|
}
|
|
1013
1013
|
return {
|
|
@@ -1024,16 +1024,16 @@ async function Yt(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le,
|
|
|
1024
1024
|
async disconnect() {
|
|
1025
1025
|
var g;
|
|
1026
1026
|
if (E) {
|
|
1027
|
-
const p =
|
|
1027
|
+
const p = Pe(I.iceConnectionState);
|
|
1028
1028
|
if (I) {
|
|
1029
|
-
if (p ===
|
|
1029
|
+
if (p === b.New) {
|
|
1030
1030
|
l.stop();
|
|
1031
1031
|
return;
|
|
1032
1032
|
}
|
|
1033
1033
|
I.close(), I.oniceconnectionstatechange = null, I.onnegotiationneeded = null, I.onicecandidate = null, I.ontrack = null;
|
|
1034
1034
|
}
|
|
1035
1035
|
try {
|
|
1036
|
-
p ===
|
|
1036
|
+
p === b.Connected && await M(E, N).catch((D) => {
|
|
1037
1037
|
});
|
|
1038
1038
|
} catch (D) {
|
|
1039
1039
|
i("Error on close stream connection", D);
|
|
@@ -1070,7 +1070,7 @@ async function Yt(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le,
|
|
|
1070
1070
|
};
|
|
1071
1071
|
}
|
|
1072
1072
|
var pe = /* @__PURE__ */ ((e) => (e.V1 = "v1", e.V2 = "v2", e))(pe || {});
|
|
1073
|
-
async function
|
|
1073
|
+
async function Qt(e, t, r, a) {
|
|
1074
1074
|
const c = e.id;
|
|
1075
1075
|
switch (t.version) {
|
|
1076
1076
|
case "v1": {
|
|
@@ -1081,7 +1081,7 @@ async function Gt(e, t, r, a) {
|
|
|
1081
1081
|
const { version: s, ...o } = t;
|
|
1082
1082
|
switch (o.transport.provider) {
|
|
1083
1083
|
case he.Livekit:
|
|
1084
|
-
const { createLiveKitStreamingManager: n } = await import("./livekit-manager-
|
|
1084
|
+
const { createLiveKitStreamingManager: n } = await import("./livekit-manager-B01_ssBG.js");
|
|
1085
1085
|
return n(c, o, r);
|
|
1086
1086
|
default:
|
|
1087
1087
|
throw new Error(`Unsupported transport provider: ${o.transport.provider}`);
|
|
@@ -1091,15 +1091,15 @@ async function Gt(e, t, r, a) {
|
|
|
1091
1091
|
throw new Error(`Invalid stream version: ${t.version}`);
|
|
1092
1092
|
}
|
|
1093
1093
|
}
|
|
1094
|
-
const
|
|
1095
|
-
function
|
|
1094
|
+
const Zt = "cht";
|
|
1095
|
+
function er() {
|
|
1096
1096
|
return {
|
|
1097
1097
|
transport: {
|
|
1098
1098
|
provider: he.Livekit
|
|
1099
1099
|
}
|
|
1100
1100
|
};
|
|
1101
1101
|
}
|
|
1102
|
-
function
|
|
1102
|
+
function tr(e) {
|
|
1103
1103
|
var c, s;
|
|
1104
1104
|
const { streamOptions: t } = e ?? {}, r = ((c = e == null ? void 0 : e.mixpanelAdditionalProperties) == null ? void 0 : c.plan) !== void 0 ? {
|
|
1105
1105
|
plan: (s = e.mixpanelAdditionalProperties) == null ? void 0 : s.plan
|
|
@@ -1112,16 +1112,16 @@ function er(e) {
|
|
|
1112
1112
|
fluent: t == null ? void 0 : t.fluent
|
|
1113
1113
|
}, ...r && { end_user_data: r } };
|
|
1114
1114
|
}
|
|
1115
|
-
function
|
|
1116
|
-
return we(e.presenter.type) ? { version: pe.V2, ...
|
|
1115
|
+
function rr(e, t) {
|
|
1116
|
+
return we(e.presenter.type) ? { version: pe.V2, ...er() } : { version: pe.V1, ...tr(t) };
|
|
1117
1117
|
}
|
|
1118
|
-
function
|
|
1118
|
+
function nr(e, t, r) {
|
|
1119
1119
|
r.track("agent-connection-state-change", { state: e, ...t && { reason: t } });
|
|
1120
1120
|
}
|
|
1121
|
-
function nr(e, t, r, a, c) {
|
|
1122
|
-
c === W.Fluent ? ar(e, t, r, a, c) : ir(e, t, r, a, c);
|
|
1123
|
-
}
|
|
1124
1121
|
function ar(e, t, r, a, c) {
|
|
1122
|
+
c === W.Fluent ? ir(e, t, r, a, c) : sr(e, t, r, a, c);
|
|
1123
|
+
}
|
|
1124
|
+
function ir(e, t, r, a, c) {
|
|
1125
1125
|
e === S.Start ? a.track("stream-session", { event: "start", "stream-type": c }) : e === S.Stop && a.track("stream-session", {
|
|
1126
1126
|
event: "stop",
|
|
1127
1127
|
is_greenscreen: t.presenter.type === "clip" && t.presenter.is_greenscreen,
|
|
@@ -1130,7 +1130,7 @@ function ar(e, t, r, a, c) {
|
|
|
1130
1130
|
...r
|
|
1131
1131
|
});
|
|
1132
1132
|
}
|
|
1133
|
-
function
|
|
1133
|
+
function $e(e, t, r, a, c) {
|
|
1134
1134
|
e === S.Start ? r.linkTrack("agent-video", { event: "start", ...c, "stream-type": a }, "start", [
|
|
1135
1135
|
x.StreamVideoCreated
|
|
1136
1136
|
]) : e === S.Stop && r.linkTrack(
|
|
@@ -1145,7 +1145,7 @@ function je(e, t, r, a, c) {
|
|
|
1145
1145
|
[x.StreamVideoDone]
|
|
1146
1146
|
);
|
|
1147
1147
|
}
|
|
1148
|
-
function
|
|
1148
|
+
function sr(e, t, r, a, c) {
|
|
1149
1149
|
e === S.Start ? a.linkTrack(
|
|
1150
1150
|
"agent-video",
|
|
1151
1151
|
{ event: "start", latency: H.get(!0), "stream-type": c },
|
|
@@ -1164,7 +1164,7 @@ function ir(e, t, r, a, c) {
|
|
|
1164
1164
|
[x.StreamVideoDone]
|
|
1165
1165
|
);
|
|
1166
1166
|
}
|
|
1167
|
-
function
|
|
1167
|
+
function or(e, t, r) {
|
|
1168
1168
|
const a = {
|
|
1169
1169
|
call_id: t.call_id,
|
|
1170
1170
|
name: t.name
|
|
@@ -1185,13 +1185,13 @@ function Be(e, t, r, a) {
|
|
|
1185
1185
|
return H.reset(), be.update(), new Promise(async (c, s) => {
|
|
1186
1186
|
try {
|
|
1187
1187
|
let o, n = !1;
|
|
1188
|
-
const i =
|
|
1188
|
+
const i = rr(e, t);
|
|
1189
1189
|
r.enrich({
|
|
1190
1190
|
"stream-version": i.version.toString()
|
|
1191
1191
|
});
|
|
1192
1192
|
let d = null;
|
|
1193
1193
|
const u = e.presenter.type === "expressive";
|
|
1194
|
-
o = await
|
|
1194
|
+
o = await Qt(
|
|
1195
1195
|
e,
|
|
1196
1196
|
i,
|
|
1197
1197
|
{
|
|
@@ -1201,11 +1201,11 @@ function Be(e, t, r, a) {
|
|
|
1201
1201
|
...t.callbacks,
|
|
1202
1202
|
onConnectionStateChange: (m, f) => {
|
|
1203
1203
|
var w, y;
|
|
1204
|
-
(y = (w = t.callbacks).onConnectionStateChange) == null || y.call(w, m),
|
|
1204
|
+
(y = (w = t.callbacks).onConnectionStateChange) == null || y.call(w, m), nr(m, f, r), m === b.Connected && (o ? c(o) : n = !0);
|
|
1205
1205
|
},
|
|
1206
1206
|
onVideoStateChange: (m, f) => {
|
|
1207
1207
|
var w, y;
|
|
1208
|
-
(y = (w = t.callbacks).onVideoStateChange) == null || y.call(w, m),
|
|
1208
|
+
(y = (w = t.callbacks).onVideoStateChange) == null || y.call(w, m), ar(
|
|
1209
1209
|
m,
|
|
1210
1210
|
e,
|
|
1211
1211
|
f,
|
|
@@ -1216,14 +1216,14 @@ function Be(e, t, r, a) {
|
|
|
1216
1216
|
onAgentActivityStateChange: (m) => {
|
|
1217
1217
|
var f, w;
|
|
1218
1218
|
(w = (f = t.callbacks).onAgentActivityStateChange) == null || w.call(f, m), m === ne.Talking ? (ge.update(), d = (y) => {
|
|
1219
|
-
|
|
1219
|
+
$e(
|
|
1220
1220
|
S.Start,
|
|
1221
1221
|
e,
|
|
1222
1222
|
r,
|
|
1223
1223
|
o.streamType,
|
|
1224
1224
|
y
|
|
1225
1225
|
), d = null;
|
|
1226
|
-
}, u || d({ latency: H.get(!0) })) : (ge.reset(), d = null,
|
|
1226
|
+
}, u || d({ latency: H.get(!0) })) : (ge.reset(), d = null, $e(
|
|
1227
1227
|
S.Stop,
|
|
1228
1228
|
e,
|
|
1229
1229
|
r,
|
|
@@ -1239,7 +1239,7 @@ function Be(e, t, r, a) {
|
|
|
1239
1239
|
},
|
|
1240
1240
|
onToolEvent: ((m, f) => {
|
|
1241
1241
|
var w, y;
|
|
1242
|
-
(y = (w = t.callbacks).onToolEvent) == null || y.call(w, m, f),
|
|
1242
|
+
(y = (w = t.callbacks).onToolEvent) == null || y.call(w, m, f), or(m, f, r);
|
|
1243
1243
|
})
|
|
1244
1244
|
}
|
|
1245
1245
|
},
|
|
@@ -1250,13 +1250,13 @@ function Be(e, t, r, a) {
|
|
|
1250
1250
|
}
|
|
1251
1251
|
});
|
|
1252
1252
|
}
|
|
1253
|
-
async function
|
|
1253
|
+
async function cr(e, t, r, a, c) {
|
|
1254
1254
|
var u, m, f, w;
|
|
1255
1255
|
const s = async () => {
|
|
1256
1256
|
if (we(e.presenter.type)) {
|
|
1257
|
-
const y = await Be(e, t, a), j = `${
|
|
1257
|
+
const y = await Be(e, t, a), j = `${Zt}_${y.sessionId}`, M = (/* @__PURE__ */ new Date()).toISOString();
|
|
1258
1258
|
return { chatResult: {
|
|
1259
|
-
chatMode:
|
|
1259
|
+
chatMode: A.Functional,
|
|
1260
1260
|
chat: {
|
|
1261
1261
|
id: j,
|
|
1262
1262
|
agent_id: e.id,
|
|
@@ -1265,7 +1265,7 @@ async function or(e, t, r, a, c) {
|
|
|
1265
1265
|
modified: M,
|
|
1266
1266
|
agent_id__created_at: M,
|
|
1267
1267
|
agent_id__modified_at: M,
|
|
1268
|
-
chat_mode:
|
|
1268
|
+
chat_mode: A.Functional,
|
|
1269
1269
|
messages: []
|
|
1270
1270
|
}
|
|
1271
1271
|
}, streamingManager: y };
|
|
@@ -1273,7 +1273,7 @@ async function or(e, t, r, a, c) {
|
|
|
1273
1273
|
const y = new AbortController(), j = y.signal;
|
|
1274
1274
|
let M;
|
|
1275
1275
|
try {
|
|
1276
|
-
const _ =
|
|
1276
|
+
const _ = Oe(
|
|
1277
1277
|
e,
|
|
1278
1278
|
r,
|
|
1279
1279
|
a,
|
|
@@ -1288,37 +1288,37 @@ async function or(e, t, r, a, c) {
|
|
|
1288
1288
|
}
|
|
1289
1289
|
}
|
|
1290
1290
|
}, { chatResult: o, streamingManager: n } = await s(), { chat: i, chatMode: d } = o;
|
|
1291
|
-
return d && t.mode !== void 0 && d !== t.mode && (t.mode = d, (m = (u = t.callbacks).onModeChange) == null || m.call(u, d), d !==
|
|
1291
|
+
return d && t.mode !== void 0 && d !== t.mode && (t.mode = d, (m = (u = t.callbacks).onModeChange) == null || m.call(u, d), d !== A.Functional) ? ((w = (f = t.callbacks).onError) == null || w.call(f, new Qe(d)), n == null || n.disconnect(), { chat: i }) : { chat: i, streamingManager: n };
|
|
1292
1292
|
}
|
|
1293
|
-
async function
|
|
1293
|
+
async function fr(e, t) {
|
|
1294
1294
|
var V, ie, se, Q;
|
|
1295
1295
|
let r = !0;
|
|
1296
|
-
const a = t.mixpanelKey ||
|
|
1296
|
+
const a = t.mixpanelKey || ft, c = t.wsURL || mt, s = t.baseURL || le, o = t.mode || A.Functional, n = {
|
|
1297
1297
|
messages: [],
|
|
1298
1298
|
chatMode: o
|
|
1299
|
-
}, i =
|
|
1299
|
+
}, i = _t({
|
|
1300
1300
|
token: a,
|
|
1301
1301
|
agentId: e,
|
|
1302
1302
|
isEnabled: t.enableAnalitics,
|
|
1303
1303
|
externalId: t.externalId,
|
|
1304
1304
|
mixpanelAdditionalProperties: t.mixpanelAdditionalProperties
|
|
1305
1305
|
}), d = Date.now();
|
|
1306
|
-
|
|
1306
|
+
Ae(() => {
|
|
1307
1307
|
i.track("agent-sdk", { event: "init" }, d);
|
|
1308
1308
|
});
|
|
1309
1309
|
const u = t.callbacks.onError;
|
|
1310
1310
|
t.callbacks.onError = (l, h) => {
|
|
1311
|
-
i.track("agent-error", { error:
|
|
1311
|
+
i.track("agent-error", { error: _e(l) }), u == null || u(l, h);
|
|
1312
1312
|
};
|
|
1313
|
-
const m =
|
|
1313
|
+
const m = kt(t.auth, s, t.callbacks.onError, t.externalId), f = await m.getById(e);
|
|
1314
1314
|
t.debug = t.debug || ((V = f == null ? void 0 : f.advanced_settings) == null ? void 0 : V.ui_debug_mode);
|
|
1315
1315
|
const w = we(f.presenter.type);
|
|
1316
|
-
i.enrich(
|
|
1317
|
-
const { onMessage: y, clearQueue: j } =
|
|
1316
|
+
i.enrich(It(f));
|
|
1317
|
+
const { onMessage: y, clearQueue: j } = $t(i, n, t, f, () => {
|
|
1318
1318
|
var l, h, v;
|
|
1319
|
-
(l = n.socketManager) == null || l.disconnect(), (v = (h = t.callbacks).onConnectionStateChange) == null || v.call(h,
|
|
1319
|
+
(l = n.socketManager) == null || l.disconnect(), (v = (h = t.callbacks).onConnectionStateChange) == null || v.call(h, b.Disconnected);
|
|
1320
1320
|
});
|
|
1321
|
-
n.messages =
|
|
1321
|
+
n.messages = At(t.initialMessages), (se = (ie = t.callbacks).onNewMessage) == null || se.call(ie, [...n.messages], "answer");
|
|
1322
1322
|
const M = (l) => {
|
|
1323
1323
|
}, _ = ({ type: l }) => {
|
|
1324
1324
|
var v, C, k, R;
|
|
@@ -1358,19 +1358,19 @@ async function mr(e, t) {
|
|
|
1358
1358
|
L.delete(l), (v = (h = n.streamingManager) == null ? void 0 : h.unregisterRpcMethod) == null || v.call(h, l);
|
|
1359
1359
|
}
|
|
1360
1360
|
const ae = Date.now();
|
|
1361
|
-
|
|
1362
|
-
i.track("agent-sdk", { event: "loaded", ...
|
|
1361
|
+
Ae(() => {
|
|
1362
|
+
i.track("agent-sdk", { event: "loaded", ...Rt(f) }, ae);
|
|
1363
1363
|
});
|
|
1364
1364
|
async function X(l) {
|
|
1365
|
-
var P, z, F, g, p, D,
|
|
1366
|
-
|
|
1367
|
-
const h = o ===
|
|
1365
|
+
var P, z, F, g, p, D, $;
|
|
1366
|
+
dt(), (z = (P = t.callbacks).onConnectionStateChange) == null || z.call(P, b.Connecting), H.reset(), l && !r && (delete n.chat, (g = (F = t.callbacks).onNewMessage) == null || g.call(F, [...n.messages], "answer"));
|
|
1367
|
+
const h = o === A.DirectPlayback || w ? Promise.resolve(void 0) : Lt(
|
|
1368
1368
|
t.auth,
|
|
1369
1369
|
c,
|
|
1370
1370
|
{ onMessage: y, onError: t.callbacks.onError },
|
|
1371
1371
|
t.externalId
|
|
1372
1372
|
), v = fe(
|
|
1373
|
-
() =>
|
|
1373
|
+
() => cr(
|
|
1374
1374
|
f,
|
|
1375
1375
|
{
|
|
1376
1376
|
...t,
|
|
@@ -1387,16 +1387,16 @@ async function mr(e, t) {
|
|
|
1387
1387
|
),
|
|
1388
1388
|
{
|
|
1389
1389
|
limit: 3,
|
|
1390
|
-
timeout:
|
|
1390
|
+
timeout: lt,
|
|
1391
1391
|
timeoutErrorMessage: "Timeout initializing the stream",
|
|
1392
1392
|
shouldRetryFn: (K) => (K == null ? void 0 : K.message) !== "Could not connect" && K.status !== 429 && (K == null ? void 0 : K.message) !== "InsufficientCreditsError",
|
|
1393
1393
|
delayMs: 1e3
|
|
1394
1394
|
}
|
|
1395
1395
|
).catch((K) => {
|
|
1396
1396
|
var T, U;
|
|
1397
|
-
throw O(
|
|
1397
|
+
throw O(A.Maintenance), (U = (T = t.callbacks).onConnectionStateChange) == null || U.call(T, b.Fail), K;
|
|
1398
1398
|
}), [C, { streamingManager: k, chat: R }] = await Promise.all([h, v]);
|
|
1399
|
-
R && R.id !== ((p = n.chat) == null ? void 0 : p.id) && ((
|
|
1399
|
+
R && R.id !== ((p = n.chat) == null ? void 0 : p.id) && (($ = (D = t.callbacks).onNewChat) == null || $.call(D, R.id)), n.streamingManager = k, n.socketManager = C, n.chat = R, q(), r = !1, i.enrich({
|
|
1400
1400
|
chatId: R == null ? void 0 : R.id,
|
|
1401
1401
|
streamId: k == null ? void 0 : k.streamId,
|
|
1402
1402
|
mode: n.chatMode
|
|
@@ -1404,11 +1404,11 @@ async function mr(e, t) {
|
|
|
1404
1404
|
}
|
|
1405
1405
|
async function I() {
|
|
1406
1406
|
var l, h, v, C;
|
|
1407
|
-
(l = n.socketManager) == null || l.disconnect(), await ((h = n.streamingManager) == null ? void 0 : h.disconnect()), delete n.streamingManager, delete n.socketManager, (C = (v = t.callbacks).onConnectionStateChange) == null || C.call(v,
|
|
1407
|
+
(l = n.socketManager) == null || l.disconnect(), await ((h = n.streamingManager) == null ? void 0 : h.disconnect()), delete n.streamingManager, delete n.socketManager, (C = (v = t.callbacks).onConnectionStateChange) == null || C.call(v, b.Disconnected);
|
|
1408
1408
|
}
|
|
1409
1409
|
async function O(l) {
|
|
1410
1410
|
var h, v;
|
|
1411
|
-
l !== n.chatMode && (i.track("agent-mode-change", { mode: l }), n.chatMode = l, n.chatMode !==
|
|
1411
|
+
l !== n.chatMode && (i.track("agent-mode-change", { mode: l }), n.chatMode = l, n.chatMode !== A.Functional && await I(), (v = (h = t.callbacks).onModeChange) == null || v.call(h, l));
|
|
1412
1412
|
}
|
|
1413
1413
|
return {
|
|
1414
1414
|
agent: f,
|
|
@@ -1477,24 +1477,24 @@ async function mr(e, t) {
|
|
|
1477
1477
|
async chat(l) {
|
|
1478
1478
|
var k, R, P, z, F;
|
|
1479
1479
|
const h = () => {
|
|
1480
|
-
if (
|
|
1481
|
-
throw new
|
|
1482
|
-
if (l.length >=
|
|
1483
|
-
throw new
|
|
1480
|
+
if (Ue(o))
|
|
1481
|
+
throw new Y(`${o} is enabled, chat is disabled`);
|
|
1482
|
+
if (l.length >= ke)
|
|
1483
|
+
throw new Y(`Message cannot be more than ${ke} characters`);
|
|
1484
1484
|
if (l.length === 0)
|
|
1485
|
-
throw new
|
|
1486
|
-
if (n.chatMode ===
|
|
1487
|
-
throw new
|
|
1488
|
-
if (![
|
|
1485
|
+
throw new Y("Message cannot be empty");
|
|
1486
|
+
if (n.chatMode === A.Maintenance)
|
|
1487
|
+
throw new Y("Chat is in maintenance mode");
|
|
1488
|
+
if (![A.TextOnly, A.Playground].includes(n.chatMode)) {
|
|
1489
1489
|
if (!n.streamingManager)
|
|
1490
|
-
throw new
|
|
1490
|
+
throw new Y("Streaming manager is not initialized");
|
|
1491
1491
|
if (!n.chat)
|
|
1492
|
-
throw new
|
|
1492
|
+
throw new Y("Chat is not initialized");
|
|
1493
1493
|
}
|
|
1494
1494
|
}, v = async () => {
|
|
1495
1495
|
var g, p;
|
|
1496
1496
|
if (!n.chat) {
|
|
1497
|
-
const D = await
|
|
1497
|
+
const D = await Oe(
|
|
1498
1498
|
f,
|
|
1499
1499
|
m,
|
|
1500
1500
|
i,
|
|
@@ -1507,7 +1507,7 @@ async function mr(e, t) {
|
|
|
1507
1507
|
}
|
|
1508
1508
|
return n.chat.id;
|
|
1509
1509
|
}, C = async (g, p) => {
|
|
1510
|
-
const D = n.chatMode ===
|
|
1510
|
+
const D = n.chatMode === A.Playground;
|
|
1511
1511
|
return fe(w && !D ? async () => {
|
|
1512
1512
|
var T, U;
|
|
1513
1513
|
return await ((U = (T = n.streamingManager) == null ? void 0 : T.sendTextMessage) == null ? void 0 : U.call(T, l)), Promise.resolve({});
|
|
@@ -1520,10 +1520,10 @@ async function mr(e, t) {
|
|
|
1520
1520
|
chatMode: n.chatMode,
|
|
1521
1521
|
streamId: (T = n.streamingManager) == null ? void 0 : T.streamId,
|
|
1522
1522
|
sessionId: (U = n.streamingManager) == null ? void 0 : U.sessionId,
|
|
1523
|
-
messages: g.map(({ matches:
|
|
1523
|
+
messages: g.map(({ matches: qe, ...oe }) => oe)
|
|
1524
1524
|
},
|
|
1525
1525
|
{
|
|
1526
|
-
...
|
|
1526
|
+
...Je(n.chatMode),
|
|
1527
1527
|
skipErrorHandler: !0
|
|
1528
1528
|
}
|
|
1529
1529
|
);
|
|
@@ -1541,7 +1541,7 @@ async function mr(e, t) {
|
|
|
1541
1541
|
};
|
|
1542
1542
|
try {
|
|
1543
1543
|
j(), h(), n.messages.push({
|
|
1544
|
-
id:
|
|
1544
|
+
id: G(),
|
|
1545
1545
|
role: "user",
|
|
1546
1546
|
content: l,
|
|
1547
1547
|
parts: re(l),
|
|
@@ -1549,7 +1549,7 @@ async function mr(e, t) {
|
|
|
1549
1549
|
}), (R = (k = t.callbacks).onNewMessage) == null || R.call(k, [...n.messages], "user");
|
|
1550
1550
|
const g = await v(), p = await C([...n.messages], g);
|
|
1551
1551
|
return p.result && n.messages.push({
|
|
1552
|
-
id:
|
|
1552
|
+
id: G(),
|
|
1553
1553
|
role: "assistant",
|
|
1554
1554
|
content: p.result,
|
|
1555
1555
|
parts: re(p.result),
|
|
@@ -1567,7 +1567,7 @@ async function mr(e, t) {
|
|
|
1567
1567
|
throw ((F = n.messages[n.messages.length - 1]) == null ? void 0 : F.role) === "assistant" && n.messages.pop(), i.track("agent-message-send", {
|
|
1568
1568
|
event: "error",
|
|
1569
1569
|
messages: n.messages.length,
|
|
1570
|
-
error:
|
|
1570
|
+
error: _e(g)
|
|
1571
1571
|
}), g;
|
|
1572
1572
|
}
|
|
1573
1573
|
},
|
|
@@ -1629,12 +1629,12 @@ async function mr(e, t) {
|
|
|
1629
1629
|
}
|
|
1630
1630
|
const v = h();
|
|
1631
1631
|
if (i.track("agent-speak", v), H.update(), n.messages && v.type === "text" && (n.messages.push({
|
|
1632
|
-
id:
|
|
1632
|
+
id: G(),
|
|
1633
1633
|
role: "assistant",
|
|
1634
1634
|
content: v.input,
|
|
1635
1635
|
parts: re(v.input),
|
|
1636
1636
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1637
|
-
}), (R = (k = t.callbacks).onNewMessage) == null || R.call(k, [...n.messages], "answer")),
|
|
1637
|
+
}), (R = (k = t.callbacks).onNewMessage) == null || R.call(k, [...n.messages], "answer")), ht(n.chatMode))
|
|
1638
1638
|
return {
|
|
1639
1639
|
duration: 0,
|
|
1640
1640
|
video_id: "",
|
|
@@ -1654,36 +1654,36 @@ async function mr(e, t) {
|
|
|
1654
1654
|
}
|
|
1655
1655
|
export {
|
|
1656
1656
|
ne as A,
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1657
|
+
B as C,
|
|
1658
|
+
st as D,
|
|
1659
|
+
it as K,
|
|
1660
|
+
tt as P,
|
|
1661
|
+
nt as R,
|
|
1662
1662
|
x as S,
|
|
1663
1663
|
he as T,
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1664
|
+
et as U,
|
|
1665
|
+
Y as V,
|
|
1666
|
+
Ze as W,
|
|
1667
|
+
zt as a,
|
|
1668
1668
|
W as b,
|
|
1669
|
-
|
|
1669
|
+
We as c,
|
|
1670
1670
|
le as d,
|
|
1671
|
-
|
|
1671
|
+
b as e,
|
|
1672
1672
|
te as f,
|
|
1673
|
-
|
|
1674
|
-
|
|
1673
|
+
Ot as g,
|
|
1674
|
+
mr as h,
|
|
1675
1675
|
S as i,
|
|
1676
|
-
|
|
1676
|
+
rt as j,
|
|
1677
1677
|
Ye as k,
|
|
1678
1678
|
H as l,
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1679
|
+
A as m,
|
|
1680
|
+
ur as n,
|
|
1681
|
+
Qe as o,
|
|
1682
|
+
ot as p,
|
|
1683
|
+
at as q,
|
|
1684
|
+
ze as r,
|
|
1685
|
+
ct as s,
|
|
1686
|
+
fr as t,
|
|
1687
|
+
lr as u,
|
|
1688
|
+
yt as v
|
|
1689
1689
|
};
|