@d-id/client-sdk 3.0.0-staging.424 → 3.0.0-staging.426
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-DevXbquF.js → index-D_aN1Y2k.js} +251 -251
- package/dist/index-D_aN1Y2k.js.map +1 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.js +1 -1
- package/dist/index.umd.cjs +5 -5
- package/dist/{livekit-manager-Bfdgu_0H.js → livekit-manager-CAbeu0Rj.js} +2 -2
- package/dist/{livekit-manager-Bfdgu_0H.js.map → livekit-manager-CAbeu0Rj.js.map} +1 -1
- package/package.json +1 -1
- package/dist/index-DevXbquF.js.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var
|
|
2
|
-
var Et = (e, t, r) => t in e ?
|
|
1
|
+
var Rt = Object.defineProperty;
|
|
2
|
+
var Et = (e, t, r) => t in e ? Rt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
3
|
var x = (e, t, r) => Et(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
-
var
|
|
4
|
+
var Re = /* @__PURE__ */ ((e) => (e.Chat = "lk.chat", e.Speak = "did.speak", e.Interrupt = "did.interrupt", e.SttLanguage = "did.stt-language", e.Presentation = "did.presentation", e))(Re || {}), L = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e.Off = "Off", e))(L || {}), F = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Transcribe = "transcribe", e.Complete = "done", e))(F || {}), ne = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e.Expressive = "expressive", e.Image = "image", e))(ne || {}), C = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(C || {}), ge = /* @__PURE__ */ ((e) => (e.Strong = "STRONG", e.Weak = "WEAK", e.Unknown = "UNKNOWN", e))(ge || {}), we = /* @__PURE__ */ ((e) => (e.Idle = "IDLE", e.Loading = "LOADING", e.Talking = "TALKING", e.ToolActive = "TOOL_ACTIVE", e))(we || {}), k = /* @__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.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.TurnStarted = "turn/started", e.TurnEnded = "turn/ended", e))(k || {}), Be = /* @__PURE__ */ ((e) => (e.Started = "tool-call/started", e.Done = "tool-call/done", e.Error = "tool-call/error", e))(Be || {}), kt = /* @__PURE__ */ ((e) => (e.Presentation = "did.presentation", e))(kt || {}), R = /* @__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))(R || {}), H = /* @__PURE__ */ ((e) => (e.Legacy = "legacy", e.Fluent = "fluent", e))(H || {}), he = /* @__PURE__ */ ((e) => (e.Ok = "ok", e.UnknownError = "unknown_error", e.NetworkIssue = "network_issue", e.MessageLimit = "message_limit", e.TimeLimit = "time_limit", e.Inactivity = "inactivity", e.EndedByAgent = "ended_by_agent", e))(he || {}), Fe = /* @__PURE__ */ ((e) => (e.Livekit = "livekit", e))(Fe || {}), Tt = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.AzureOpenAi = "azure-openai", e.Microsoft = "microsoft", e.Elevenlabs = "elevenlabs", e.Cartesia = "cartesia", e))(Tt || {}), _t = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e.ExternalPrivate = "external-private", e))(_t || {});
|
|
5
5
|
const Jn = (...e) => {
|
|
6
6
|
}, ft = (e) => new Promise((t) => setTimeout(t, e)), Z = (e = 16) => {
|
|
7
7
|
const t = new Uint8Array(e);
|
|
8
8
|
return globalThis.crypto.getRandomValues(t), Array.from(t, (r) => r.toString(16).padStart(2, "0")).join("").slice(0, 13);
|
|
9
9
|
};
|
|
10
|
-
function
|
|
10
|
+
function $e(e) {
|
|
11
11
|
if (e !== void 0)
|
|
12
12
|
return window.localStorage.setItem("did_external_key_id", e), e;
|
|
13
13
|
let t = window.localStorage.getItem("did_external_key_id");
|
|
@@ -18,7 +18,7 @@ function Be(e) {
|
|
|
18
18
|
return t;
|
|
19
19
|
}
|
|
20
20
|
let mt;
|
|
21
|
-
function
|
|
21
|
+
function Ae() {
|
|
22
22
|
return mt ?? (mt = Z());
|
|
23
23
|
}
|
|
24
24
|
function At() {
|
|
@@ -26,14 +26,14 @@ function At() {
|
|
|
26
26
|
}
|
|
27
27
|
function gt(e, t) {
|
|
28
28
|
if (e.type === "bearer")
|
|
29
|
-
return `Bearer ${e.token}~${
|
|
29
|
+
return `Bearer ${e.token}~${Ae()}`;
|
|
30
30
|
if (e.type === "basic")
|
|
31
|
-
return `Basic ${"token" in e ? e.token : btoa(`${e.username}:${e.password}`)}~${
|
|
31
|
+
return `Basic ${"token" in e ? e.token : btoa(`${e.username}:${e.password}`)}~${Ae()}`;
|
|
32
32
|
if (e.type === "key")
|
|
33
|
-
return `Client-Key ${e.clientKey}.${
|
|
33
|
+
return `Client-Key ${e.clientKey}.${$e(t)}_${Ae()}`;
|
|
34
34
|
throw new Error(`Unknown auth type: ${e}`);
|
|
35
35
|
}
|
|
36
|
-
const Pt = 45 * 1e3, bt = "X-Playground-Chat", He = 2e3,
|
|
36
|
+
const Pt = 45 * 1e3, bt = "X-Playground-Chat", He = 2e3, ke = "https://api.d-id.com", xt = "wss://notifications.d-id.com", Lt = "79f81a83a67430be2bc0fd61042b8faa";
|
|
37
37
|
class q extends Error {
|
|
38
38
|
/**
|
|
39
39
|
* Creates an SDK error. The SDK builds these itself; applications normally only catch them.
|
|
@@ -262,7 +262,7 @@ class pt extends q {
|
|
|
262
262
|
x(this, "kind", "StreamError");
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
|
-
class
|
|
265
|
+
class I extends q {
|
|
266
266
|
/**
|
|
267
267
|
* Builds a validation failure. The SDK does this itself before it performs a request.
|
|
268
268
|
*
|
|
@@ -292,13 +292,13 @@ class Ot extends q {
|
|
|
292
292
|
x(this, "kind", "WSError");
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
|
-
const
|
|
295
|
+
const wt = (e) => e.type, zt = (e) => e.type === ne.Expressive ? "v4" : e.type === ne.Clip ? "v3-pro" : e.type === ne.Image ? "image" : "v2", Ve = (e) => e === ne.Expressive || e === ne.Image, Pe = (e) => [L.TextOnly, L.Playground, L.Maintenance].includes(e), te = (e) => e && [L.DirectPlayback, L.Off].includes(e), We = /\[!\[([^\[\]]*)\]\(([^)\s]+)\)\]\(([^)\s]+)\)/g, Ke = /!\[([^\[\]]*)\]\(([^)\s]+)\)/g, Ft = [".mp4", ".webm", ".mkv", ".mov", ".m4v", ".ogv"];
|
|
296
296
|
function Vt(e) {
|
|
297
297
|
const t = e.split("?")[0].split("#")[0].toLowerCase();
|
|
298
298
|
return Ft.some((r) => t.endsWith(r));
|
|
299
299
|
}
|
|
300
300
|
const qe = new RegExp("(?<!!)\\[([^\\[\\]]+)\\]\\(([^)\\s]+)\\)", "g"), Ge = /<a\s+href="([^"]*)"[^>]*?>([^<]*)<\/a>/gi;
|
|
301
|
-
function
|
|
301
|
+
function yt(e) {
|
|
302
302
|
if (e.length === 0)
|
|
303
303
|
return [];
|
|
304
304
|
const t = [];
|
|
@@ -336,9 +336,9 @@ function wt(e) {
|
|
|
336
336
|
s.index > o && a.push({ type: "text", text: e.slice(o, s.index) }), a.push(s.part), o = s.index + s.length;
|
|
337
337
|
return o < e.length && a.push({ type: "text", text: e.slice(o) }), a;
|
|
338
338
|
}
|
|
339
|
-
let Xe = "",
|
|
340
|
-
function
|
|
341
|
-
return e === Xe || (Xe = e,
|
|
339
|
+
let Xe = "", be = [];
|
|
340
|
+
function pe(e) {
|
|
341
|
+
return e === Xe || (Xe = e, be = yt(e)), be;
|
|
342
342
|
}
|
|
343
343
|
function Ut(e, t) {
|
|
344
344
|
let r;
|
|
@@ -349,7 +349,7 @@ function Ut(e, t) {
|
|
|
349
349
|
clear: () => clearTimeout(r)
|
|
350
350
|
};
|
|
351
351
|
}
|
|
352
|
-
async function
|
|
352
|
+
async function Ne(e, t) {
|
|
353
353
|
const r = {
|
|
354
354
|
limit: (t == null ? void 0 : t.limit) ?? 3,
|
|
355
355
|
delayMs: (t == null ? void 0 : t.delayMs) ?? 0,
|
|
@@ -379,13 +379,13 @@ class Ye {
|
|
|
379
379
|
this.response = t;
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
|
-
const Jt = (e) =>
|
|
382
|
+
const Jt = (e) => Ne(e, {
|
|
383
383
|
limit: 3,
|
|
384
384
|
delayMs: 1e3,
|
|
385
385
|
timeout: 0,
|
|
386
386
|
shouldRetryFn: (t) => t.status === 429
|
|
387
387
|
});
|
|
388
|
-
function vt(e, t =
|
|
388
|
+
function vt(e, t = ke, r, a) {
|
|
389
389
|
const o = async (s, i) => {
|
|
390
390
|
const { skipErrorHandler: u, ...n } = i || {}, d = n.method ?? "GET", h = performance.now();
|
|
391
391
|
let f;
|
|
@@ -440,7 +440,7 @@ function vt(e, t = Ee, r, a) {
|
|
|
440
440
|
}
|
|
441
441
|
};
|
|
442
442
|
}
|
|
443
|
-
function Ht(e, t =
|
|
443
|
+
function Ht(e, t = ke, r, a) {
|
|
444
444
|
const o = vt(e, `${t}/agents`, r, a);
|
|
445
445
|
return {
|
|
446
446
|
getRuntimeById(s, i) {
|
|
@@ -480,7 +480,7 @@ function Wt(e) {
|
|
|
480
480
|
isMobile: `${t() == "Mobile"}`,
|
|
481
481
|
browser: navigator.userAgent,
|
|
482
482
|
origin: window.location.origin,
|
|
483
|
-
agentType:
|
|
483
|
+
agentType: wt(a),
|
|
484
484
|
agentVoice: {
|
|
485
485
|
language: (s = (o = e.avatar) == null ? void 0 : o.voice) == null ? void 0 : s.language
|
|
486
486
|
}
|
|
@@ -489,7 +489,7 @@ function Wt(e) {
|
|
|
489
489
|
function Kt(e) {
|
|
490
490
|
var t;
|
|
491
491
|
return {
|
|
492
|
-
agentType:
|
|
492
|
+
agentType: wt(e.avatar),
|
|
493
493
|
presenterType: zt(e.avatar),
|
|
494
494
|
owner_id: e.owner_id ?? "",
|
|
495
495
|
starterQuestionsCount: (t = e.starter_message) == null ? void 0 : t.length,
|
|
@@ -528,11 +528,11 @@ function tt(e, t, r) {
|
|
|
528
528
|
function nt(e) {
|
|
529
529
|
"requestIdleCallback" in window ? requestIdleCallback(e, { timeout: 2e3 }) : setTimeout(e, 0);
|
|
530
530
|
}
|
|
531
|
-
function
|
|
531
|
+
function xe(e) {
|
|
532
532
|
return e instanceof q ? e.toJson() : { kind: "UnknownError", message: qt(e) || "UnknownError" };
|
|
533
533
|
}
|
|
534
|
-
const Zt = "3.0.0-staging.
|
|
535
|
-
let
|
|
534
|
+
const Zt = "3.0.0-staging.426", en = "https://api-js.mixpanel.com/track/?verbose=1&ip=1", St = 50, Q = [];
|
|
535
|
+
let Le = !1;
|
|
536
536
|
async function Ct(e) {
|
|
537
537
|
const t = await fetch(en, {
|
|
538
538
|
method: "POST",
|
|
@@ -545,28 +545,28 @@ async function Ct(e) {
|
|
|
545
545
|
function tn(e) {
|
|
546
546
|
Q.push(e), Q.splice(St);
|
|
547
547
|
}
|
|
548
|
-
function
|
|
549
|
-
if (
|
|
548
|
+
function Oe() {
|
|
549
|
+
if (Le || !Q.length)
|
|
550
550
|
return;
|
|
551
|
-
|
|
551
|
+
Le = !0;
|
|
552
552
|
const e = Q.splice(0, Q.length);
|
|
553
553
|
Ct(e).catch(() => {
|
|
554
554
|
Q.unshift(...e), Q.splice(St);
|
|
555
555
|
}).finally(() => {
|
|
556
|
-
|
|
556
|
+
Le = !1;
|
|
557
557
|
});
|
|
558
558
|
}
|
|
559
|
-
typeof window < "u" && typeof window.addEventListener == "function" && (window.addEventListener("online",
|
|
560
|
-
document.visibilityState === "visible" &&
|
|
559
|
+
typeof window < "u" && typeof window.addEventListener == "function" && (window.addEventListener("online", Oe), typeof document < "u" && document.addEventListener("visibilitychange", () => {
|
|
560
|
+
document.visibilityState === "visible" && Oe();
|
|
561
561
|
}));
|
|
562
562
|
function nn(e) {
|
|
563
563
|
const t = window != null && window.hasOwnProperty("DID_AGENTS_API") ? "agents-ui" : "agents-sdk", r = {};
|
|
564
564
|
return {
|
|
565
565
|
token: e.token || "testKey",
|
|
566
|
-
distinct_id:
|
|
566
|
+
distinct_id: $e(e.externalId),
|
|
567
567
|
agentId: e.agentId,
|
|
568
568
|
additionalProperties: {
|
|
569
|
-
id:
|
|
569
|
+
id: $e(e.externalId),
|
|
570
570
|
...e.mixpanelAdditionalProperties || {}
|
|
571
571
|
},
|
|
572
572
|
isEnabled: e.isEnabled ?? !0,
|
|
@@ -595,7 +595,7 @@ function nn(e) {
|
|
|
595
595
|
"User Agent": navigator.userAgent
|
|
596
596
|
}
|
|
597
597
|
};
|
|
598
|
-
return
|
|
598
|
+
return Oe(), Ct([d]).catch(() => tn(d)), Promise.resolve();
|
|
599
599
|
},
|
|
600
600
|
linkTrack(a, o, s, i) {
|
|
601
601
|
r[a] || (r[a] = { events: {}, resolvedDependencies: [] }), i.includes(s) || i.push(s);
|
|
@@ -621,7 +621,7 @@ function Ue() {
|
|
|
621
621
|
get: (t = !1) => t ? Date.now() - e : e
|
|
622
622
|
};
|
|
623
623
|
}
|
|
624
|
-
const K = Ue(),
|
|
624
|
+
const K = Ue(), ze = Ue(), rt = Ue();
|
|
625
625
|
function Mt(e) {
|
|
626
626
|
return e === L.Playground ? { headers: { [bt]: "true" } } : {};
|
|
627
627
|
}
|
|
@@ -634,7 +634,7 @@ async function Dt(e, t, r, a, o = !1, s) {
|
|
|
634
634
|
}
|
|
635
635
|
function rn(e) {
|
|
636
636
|
return !e || e.length === 0 ? [] : e.map(
|
|
637
|
-
(t) => Array.isArray(t.parts) && t.parts.length > 0 ? t : { ...t, parts:
|
|
637
|
+
(t) => Array.isArray(t.parts) && t.parts.length > 0 ? t : { ...t, parts: yt(typeof t.content == "string" ? t.content : "") }
|
|
638
638
|
);
|
|
639
639
|
}
|
|
640
640
|
function an(e) {
|
|
@@ -683,10 +683,10 @@ async function on(e, t, r, a) {
|
|
|
683
683
|
};
|
|
684
684
|
}
|
|
685
685
|
const cn = {
|
|
686
|
-
manual:
|
|
687
|
-
inactivity:
|
|
688
|
-
peer_disconnected:
|
|
689
|
-
shutdown:
|
|
686
|
+
manual: he.Ok,
|
|
687
|
+
inactivity: he.Inactivity,
|
|
688
|
+
peer_disconnected: he.NetworkIssue,
|
|
689
|
+
shutdown: he.UnknownError
|
|
690
690
|
};
|
|
691
691
|
function dn(e) {
|
|
692
692
|
return cn[e.close_reason] ?? e.close_reason;
|
|
@@ -711,7 +711,7 @@ function ln(e, t, r) {
|
|
|
711
711
|
id: e.id || `user-${Date.now()}`,
|
|
712
712
|
role: e.role,
|
|
713
713
|
content: e.content,
|
|
714
|
-
parts:
|
|
714
|
+
parts: pe(e.content),
|
|
715
715
|
createdAt: e.created_at || (/* @__PURE__ */ new Date()).toISOString(),
|
|
716
716
|
transcribed: !0
|
|
717
717
|
};
|
|
@@ -752,7 +752,7 @@ function fn(e, t, r, a, o, s, i) {
|
|
|
752
752
|
!!(f && f.length < p.length) && (h.interrupted = !0), r.answer = f;
|
|
753
753
|
}
|
|
754
754
|
const l = it(r);
|
|
755
|
-
(h.content !== l || e === F.Answer) && (h.content = l, h.parts =
|
|
755
|
+
(h.content !== l || e === F.Answer) && (h.content = l, h.parts = pe(l), o == null || o([...a.messages], e));
|
|
756
756
|
}
|
|
757
757
|
function mn(e, t, r, a, o) {
|
|
758
758
|
const s = {}, i = () => {
|
|
@@ -850,7 +850,7 @@ function gn(e, t, r, a) {
|
|
|
850
850
|
};
|
|
851
851
|
}
|
|
852
852
|
const hn = (e, t) => (r, a) => e && console.log(`[${t}] ${r}`, a ?? ""), pn = 45;
|
|
853
|
-
function
|
|
853
|
+
function wn(e) {
|
|
854
854
|
const t = e.map((n) => n.av).filter((n) => !!n && n.audioPlayout > 0 && n.videoPlayout > 0);
|
|
855
855
|
if (t.length < 2)
|
|
856
856
|
return null;
|
|
@@ -865,7 +865,7 @@ function yn(e) {
|
|
|
865
865
|
residualOffsetMs: De(Yt(u))
|
|
866
866
|
};
|
|
867
867
|
}
|
|
868
|
-
function
|
|
868
|
+
function yn(e, t, r) {
|
|
869
869
|
const a = (t.timestamp - e.timestamp) / 1e3;
|
|
870
870
|
return {
|
|
871
871
|
duration: a,
|
|
@@ -995,11 +995,11 @@ function st(e, t, r) {
|
|
|
995
995
|
return {
|
|
996
996
|
webRTCStats: {
|
|
997
997
|
anomalies: o,
|
|
998
|
-
avSync: Qt(() =>
|
|
998
|
+
avSync: Qt(() => wn(e), null),
|
|
999
999
|
minRtt: Ze(u),
|
|
1000
1000
|
avgRtt: Qe(u),
|
|
1001
1001
|
maxRtt: et(u),
|
|
1002
|
-
aggregateReport:
|
|
1002
|
+
aggregateReport: yn(e[0], e[e.length - 1], s),
|
|
1003
1003
|
minJitterDelayInInterval: Ze(i),
|
|
1004
1004
|
maxJitterDelayInInterval: et(i),
|
|
1005
1005
|
avgJitterDelayInInterval: Qe(i)
|
|
@@ -1008,13 +1008,13 @@ function st(e, t, r) {
|
|
|
1008
1008
|
resolution: `${e[0].frameWidth}x${e[0].frameHeight}`
|
|
1009
1009
|
};
|
|
1010
1010
|
}
|
|
1011
|
-
function
|
|
1011
|
+
function It(e, t) {
|
|
1012
1012
|
for (const r of e.values())
|
|
1013
1013
|
if ((r == null ? void 0 : r.type) === "inbound-rtp" && r.kind === t)
|
|
1014
1014
|
return r;
|
|
1015
1015
|
return null;
|
|
1016
1016
|
}
|
|
1017
|
-
const
|
|
1017
|
+
const me = 10;
|
|
1018
1018
|
function Wn(e, t) {
|
|
1019
1019
|
let r = !1, a = !1, o = null, s = 0, i = 0, u = {};
|
|
1020
1020
|
async function n() {
|
|
@@ -1022,17 +1022,17 @@ function Wn(e, t) {
|
|
|
1022
1022
|
try {
|
|
1023
1023
|
const d = await e();
|
|
1024
1024
|
if (!d) {
|
|
1025
|
-
o = setTimeout(n,
|
|
1025
|
+
o = setTimeout(n, me);
|
|
1026
1026
|
return;
|
|
1027
1027
|
}
|
|
1028
|
-
const h =
|
|
1028
|
+
const h = It(d, "audio");
|
|
1029
1029
|
if (!h) {
|
|
1030
|
-
o = setTimeout(n,
|
|
1030
|
+
o = setTimeout(n, me);
|
|
1031
1031
|
return;
|
|
1032
1032
|
}
|
|
1033
1033
|
const f = h.totalAudioEnergy ?? 0, g = h.totalSamplesReceived ?? 0;
|
|
1034
1034
|
if (!a) {
|
|
1035
|
-
s = f, i = g, a = !0, o = setTimeout(n,
|
|
1035
|
+
s = f, i = g, a = !0, o = setTimeout(n, me);
|
|
1036
1036
|
return;
|
|
1037
1037
|
}
|
|
1038
1038
|
const l = f - s, p = g - i;
|
|
@@ -1042,23 +1042,23 @@ function Wn(e, t) {
|
|
|
1042
1042
|
}
|
|
1043
1043
|
} catch {
|
|
1044
1044
|
}
|
|
1045
|
-
r && (o = setTimeout(n,
|
|
1045
|
+
r && (o = setTimeout(n, me));
|
|
1046
1046
|
}
|
|
1047
1047
|
}
|
|
1048
1048
|
return {
|
|
1049
1049
|
arm(d = {}) {
|
|
1050
|
-
u = d, r = !0, a = !1, performance.now(), o !== null && clearTimeout(o), o = setTimeout(n,
|
|
1050
|
+
u = d, r = !0, a = !1, performance.now(), o !== null && clearTimeout(o), o = setTimeout(n, me);
|
|
1051
1051
|
},
|
|
1052
1052
|
destroy() {
|
|
1053
1053
|
r = !1, o !== null && (clearTimeout(o), o = null);
|
|
1054
1054
|
}
|
|
1055
1055
|
};
|
|
1056
1056
|
}
|
|
1057
|
-
const
|
|
1058
|
-
function
|
|
1057
|
+
const Ie = 100, Cn = Math.max(Math.ceil(400 / Ie), 1), Mn = 0.25, Dn = 0.28;
|
|
1058
|
+
function In() {
|
|
1059
1059
|
let e = 0, t, r, a = 0;
|
|
1060
1060
|
return (o) => {
|
|
1061
|
-
const s =
|
|
1061
|
+
const s = It(o, "video");
|
|
1062
1062
|
if (!s)
|
|
1063
1063
|
return { isReceiving: !1, avgJitterDelayInInterval: a };
|
|
1064
1064
|
const i = s.jitterBufferDelay, u = s.jitterBufferEmittedCount;
|
|
@@ -1071,29 +1071,29 @@ function Rn() {
|
|
|
1071
1071
|
return e = n, { isReceiving: d, avgJitterDelayInInterval: a, freezeCount: s.freezeCount };
|
|
1072
1072
|
};
|
|
1073
1073
|
}
|
|
1074
|
-
function
|
|
1075
|
-
let s = null, i = [], u, n = 0, d = !1, h =
|
|
1076
|
-
const p =
|
|
1074
|
+
function Rn(e, t, r, a, o) {
|
|
1075
|
+
let s = null, i = [], u, n = 0, d = !1, h = ge.Unknown, f = ge.Unknown, g = 0, l = 0;
|
|
1076
|
+
const p = In();
|
|
1077
1077
|
async function D() {
|
|
1078
1078
|
const S = await e();
|
|
1079
1079
|
if (!S)
|
|
1080
1080
|
return;
|
|
1081
|
-
const { isReceiving: P, avgJitterDelayInInterval: U, freezeCount: j } = p(S),
|
|
1081
|
+
const { isReceiving: P, avgJitterDelayInInterval: U, freezeCount: j } = p(S), re = Sn(S);
|
|
1082
1082
|
if (P)
|
|
1083
|
-
n = 0, g = j - l, f = U < Mn ?
|
|
1083
|
+
n = 0, g = j - l, f = U < Mn ? ge.Strong : U > Dn && g > 1 ? ge.Weak : h, f !== h && (o == null || o(f), h = f, l += g, g = 0), d || (a == null || a(C.Start), u = i[i.length - 1], i = [], d = !0), i.push(re);
|
|
1084
1084
|
else if (d && (n++, n >= Cn)) {
|
|
1085
|
-
const
|
|
1086
|
-
a == null || a(C.Stop,
|
|
1085
|
+
const ae = st(i, Ie, u);
|
|
1086
|
+
a == null || a(C.Stop, ae ?? void 0), t() || r(), l = j, d = !1;
|
|
1087
1087
|
}
|
|
1088
1088
|
}
|
|
1089
1089
|
return {
|
|
1090
1090
|
start: () => {
|
|
1091
|
-
s || (s = setInterval(D,
|
|
1091
|
+
s || (s = setInterval(D, Ie));
|
|
1092
1092
|
},
|
|
1093
1093
|
stop: () => {
|
|
1094
1094
|
s && (clearInterval(s), s = null);
|
|
1095
1095
|
},
|
|
1096
|
-
getReport: () => st(i,
|
|
1096
|
+
getReport: () => st(i, Ie, u)
|
|
1097
1097
|
};
|
|
1098
1098
|
}
|
|
1099
1099
|
const En = () => {
|
|
@@ -1105,21 +1105,21 @@ const En = () => {
|
|
|
1105
1105
|
function ot(e) {
|
|
1106
1106
|
switch (e) {
|
|
1107
1107
|
case "connected":
|
|
1108
|
-
return
|
|
1108
|
+
return R.Connected;
|
|
1109
1109
|
case "checking":
|
|
1110
|
-
return
|
|
1110
|
+
return R.Connecting;
|
|
1111
1111
|
case "failed":
|
|
1112
|
-
return
|
|
1112
|
+
return R.Fail;
|
|
1113
1113
|
case "new":
|
|
1114
|
-
return
|
|
1114
|
+
return R.New;
|
|
1115
1115
|
case "closed":
|
|
1116
|
-
return
|
|
1116
|
+
return R.Closed;
|
|
1117
1117
|
case "disconnected":
|
|
1118
|
-
return
|
|
1118
|
+
return R.Disconnected;
|
|
1119
1119
|
case "completed":
|
|
1120
|
-
return
|
|
1120
|
+
return R.Completed;
|
|
1121
1121
|
default:
|
|
1122
|
-
return
|
|
1122
|
+
return R.New;
|
|
1123
1123
|
}
|
|
1124
1124
|
}
|
|
1125
1125
|
const kn = (e) => (t) => {
|
|
@@ -1148,7 +1148,7 @@ function _n({
|
|
|
1148
1148
|
report: o,
|
|
1149
1149
|
log: s
|
|
1150
1150
|
}) {
|
|
1151
|
-
e === C.Start ? (s("CALLBACK: onVideoStateChange(Start)"), r == null || r(C.Start)) : e === C.Stop && (s("CALLBACK: onVideoStateChange(Stop)"), r == null || r(C.Stop, o)), t === C.Start ? a == null || a(
|
|
1151
|
+
e === C.Start ? (s("CALLBACK: onVideoStateChange(Start)"), r == null || r(C.Start)) : e === C.Stop && (s("CALLBACK: onVideoStateChange(Stop)"), r == null || r(C.Stop, o)), t === C.Start ? a == null || a(we.Talking) : t === C.Stop && (a == null || a(we.Idle));
|
|
1152
1152
|
}
|
|
1153
1153
|
function ct({
|
|
1154
1154
|
statsSignal: e,
|
|
@@ -1168,8 +1168,8 @@ function ct({
|
|
|
1168
1168
|
log: i
|
|
1169
1169
|
});
|
|
1170
1170
|
}
|
|
1171
|
-
async function An(e, t, { debug: r = !1, callbacks: a, auth: o, baseURL: s =
|
|
1172
|
-
var
|
|
1171
|
+
async function An(e, t, { debug: r = !1, callbacks: a, auth: o, baseURL: s = ke, analytics: i }, u) {
|
|
1172
|
+
var fe;
|
|
1173
1173
|
const n = hn(r, "WebRTCStreamingManager"), d = kn(n);
|
|
1174
1174
|
let h = !1, f = !1, g = C.Stop, l = C.Stop;
|
|
1175
1175
|
const { startConnection: p, sendStreamRequest: D, close: S, createStream: P, addIceCandidate: U } = gn(
|
|
@@ -1179,31 +1179,31 @@ async function An(e, t, { debug: r = !1, callbacks: a, auth: o, baseURL: s = Ee,
|
|
|
1179
1179
|
a.onError
|
|
1180
1180
|
), {
|
|
1181
1181
|
id: j,
|
|
1182
|
-
offer:
|
|
1183
|
-
ice_servers:
|
|
1182
|
+
offer: re,
|
|
1183
|
+
ice_servers: ae,
|
|
1184
1184
|
session_id: N,
|
|
1185
1185
|
fluent: ee,
|
|
1186
|
-
interrupt_enabled:
|
|
1186
|
+
interrupt_enabled: ye
|
|
1187
1187
|
} = await P(t, u);
|
|
1188
1188
|
if (!N)
|
|
1189
1189
|
throw new Error("Could not create session_id");
|
|
1190
|
-
(
|
|
1191
|
-
const
|
|
1190
|
+
(fe = a.onStreamCreated) == null || fe.call(a, { streamId: j, sessionId: N, agentId: e });
|
|
1191
|
+
const ie = (y) => {
|
|
1192
1192
|
var v;
|
|
1193
|
-
return (v = a.onError) == null ? void 0 : v.call(a,
|
|
1194
|
-
}, T = new (En())({ iceServers:
|
|
1193
|
+
return (v = a.onError) == null ? void 0 : v.call(a, y, { streamId: j });
|
|
1194
|
+
}, T = new (En())({ iceServers: ae }), G = T.createDataChannel("JanusDataChannel"), B = ee ? H.Fluent : H.Legacy;
|
|
1195
1195
|
i.enrich({
|
|
1196
1196
|
"stream-type": B
|
|
1197
1197
|
});
|
|
1198
|
-
const X = t.stream_warmup && !ee, ve = () => h,
|
|
1199
|
-
var
|
|
1200
|
-
h = !0, f && (n("CALLBACK: onConnectionStateChange(Connected)"), (
|
|
1201
|
-
}, Y =
|
|
1198
|
+
const X = t.stream_warmup && !ee, ve = () => h, se = () => {
|
|
1199
|
+
var y;
|
|
1200
|
+
h = !0, f && (n("CALLBACK: onConnectionStateChange(Connected)"), (y = a.onConnectionStateChange) == null || y.call(a, R.Connected));
|
|
1201
|
+
}, Y = Rn(
|
|
1202
1202
|
() => T.getStats(),
|
|
1203
1203
|
ve,
|
|
1204
|
-
|
|
1205
|
-
(
|
|
1206
|
-
statsSignal: l =
|
|
1204
|
+
se,
|
|
1205
|
+
(y, v) => ct({
|
|
1206
|
+
statsSignal: l = y,
|
|
1207
1207
|
dataChannelSignal: B === H.Legacy ? g : void 0,
|
|
1208
1208
|
onVideoStateChange: a.onVideoStateChange,
|
|
1209
1209
|
onAgentActivityStateChange: a.onAgentActivityStateChange,
|
|
@@ -1211,41 +1211,41 @@ async function An(e, t, { debug: r = !1, callbacks: a, auth: o, baseURL: s = Ee,
|
|
|
1211
1211
|
streamType: B,
|
|
1212
1212
|
log: n
|
|
1213
1213
|
}),
|
|
1214
|
-
(
|
|
1214
|
+
(y) => {
|
|
1215
1215
|
var v;
|
|
1216
|
-
return (v = a.onConnectivityStateChange) == null ? void 0 : v.call(a,
|
|
1216
|
+
return (v = a.onConnectivityStateChange) == null ? void 0 : v.call(a, y);
|
|
1217
1217
|
}
|
|
1218
1218
|
);
|
|
1219
|
-
Y.start(), T.onicecandidate = (
|
|
1220
|
-
n("peerConnection.onicecandidate",
|
|
1219
|
+
Y.start(), T.onicecandidate = (y) => {
|
|
1220
|
+
n("peerConnection.onicecandidate", y);
|
|
1221
1221
|
try {
|
|
1222
|
-
|
|
1222
|
+
y.candidate && y.candidate.sdpMid && y.candidate.sdpMLineIndex !== null ? U(
|
|
1223
1223
|
j,
|
|
1224
1224
|
{
|
|
1225
|
-
candidate:
|
|
1226
|
-
sdpMid:
|
|
1227
|
-
sdpMLineIndex:
|
|
1225
|
+
candidate: y.candidate.candidate,
|
|
1226
|
+
sdpMid: y.candidate.sdpMid,
|
|
1227
|
+
sdpMLineIndex: y.candidate.sdpMLineIndex
|
|
1228
1228
|
},
|
|
1229
1229
|
N,
|
|
1230
1230
|
u
|
|
1231
1231
|
) : U(j, { candidate: null }, N, u);
|
|
1232
1232
|
} catch (v) {
|
|
1233
|
-
|
|
1233
|
+
ie(v);
|
|
1234
1234
|
}
|
|
1235
1235
|
}, G.onopen = () => {
|
|
1236
|
-
f = !0, (!X || h) &&
|
|
1236
|
+
f = !0, (!X || h) && se();
|
|
1237
1237
|
};
|
|
1238
1238
|
let V = null;
|
|
1239
|
-
const
|
|
1239
|
+
const oe = (y) => {
|
|
1240
1240
|
var v;
|
|
1241
|
-
V =
|
|
1241
|
+
V = y, (v = a.onVideoIdChange) == null || v.call(a, y);
|
|
1242
1242
|
};
|
|
1243
|
-
function Se(
|
|
1244
|
-
if (
|
|
1243
|
+
function Se(y, v) {
|
|
1244
|
+
if (y === k.StreamStarted && typeof v == "object" && "metadata" in v) {
|
|
1245
1245
|
const c = v.metadata;
|
|
1246
|
-
|
|
1246
|
+
oe(c.videoId);
|
|
1247
1247
|
}
|
|
1248
|
-
|
|
1248
|
+
y === k.StreamDone && oe(null), g = y === k.StreamStarted ? C.Start : C.Stop, ct({
|
|
1249
1249
|
statsSignal: B === H.Legacy ? l : void 0,
|
|
1250
1250
|
dataChannelSignal: g,
|
|
1251
1251
|
onVideoStateChange: a.onVideoStateChange,
|
|
@@ -1254,40 +1254,40 @@ async function An(e, t, { debug: r = !1, callbacks: a, auth: o, baseURL: s = Ee,
|
|
|
1254
1254
|
log: n
|
|
1255
1255
|
});
|
|
1256
1256
|
}
|
|
1257
|
-
function
|
|
1257
|
+
function ce(y, v) {
|
|
1258
1258
|
var m;
|
|
1259
1259
|
const c = typeof v == "string" ? v : v == null ? void 0 : v.metadata;
|
|
1260
1260
|
c && i.enrich({ streamMetadata: c }), (m = a.onStreamReady) == null || m.call(a);
|
|
1261
1261
|
}
|
|
1262
|
-
const
|
|
1262
|
+
const de = {
|
|
1263
1263
|
[k.StreamStarted]: Se,
|
|
1264
1264
|
[k.StreamDone]: Se,
|
|
1265
|
-
[k.StreamReady]:
|
|
1265
|
+
[k.StreamReady]: ce
|
|
1266
1266
|
};
|
|
1267
|
-
G.onmessage = (
|
|
1267
|
+
G.onmessage = (y) => {
|
|
1268
1268
|
var m;
|
|
1269
|
-
const { subject: v, data: c } = d(
|
|
1270
|
-
(m =
|
|
1269
|
+
const { subject: v, data: c } = d(y.data);
|
|
1270
|
+
(m = de[v]) == null || m.call(de, v, c);
|
|
1271
1271
|
}, T.oniceconnectionstatechange = () => {
|
|
1272
1272
|
var v;
|
|
1273
1273
|
n("peerConnection.oniceconnectionstatechange => " + T.iceConnectionState);
|
|
1274
|
-
const
|
|
1275
|
-
|
|
1276
|
-
}, T.ontrack = (
|
|
1274
|
+
const y = ot(T.iceConnectionState);
|
|
1275
|
+
y !== R.Connected && ((v = a.onConnectionStateChange) == null || v.call(a, y, `webrtc:ice-${T.iceConnectionState}`));
|
|
1276
|
+
}, T.ontrack = (y) => {
|
|
1277
1277
|
var v;
|
|
1278
|
-
n("peerConnection.ontrack",
|
|
1279
|
-
}, await T.setRemoteDescription(
|
|
1280
|
-
const
|
|
1281
|
-
n("create answer OK"), await T.setLocalDescription(
|
|
1282
|
-
async function
|
|
1278
|
+
n("peerConnection.ontrack", y), n("CALLBACK: onSrcObjectReady"), (v = a.onSrcObjectReady) == null || v.call(a, y.streams[0]);
|
|
1279
|
+
}, await T.setRemoteDescription(re), n("set remote description OK");
|
|
1280
|
+
const ue = await T.createAnswer();
|
|
1281
|
+
n("create answer OK"), await T.setLocalDescription(ue), n("set local description OK"), await p(j, ue, N, u), n("start connection OK");
|
|
1282
|
+
async function le(y, v) {
|
|
1283
1283
|
if (!h || G.readyState !== "open") {
|
|
1284
|
-
n("Data channel is not ready for sending messages"),
|
|
1284
|
+
n("Data channel is not ready for sending messages"), ie(new pt("Data channel is not ready for sending messages"));
|
|
1285
1285
|
return;
|
|
1286
1286
|
}
|
|
1287
1287
|
try {
|
|
1288
1288
|
G.send(v);
|
|
1289
1289
|
} catch (c) {
|
|
1290
|
-
n("Error sending data channel message", c),
|
|
1290
|
+
n("Error sending data channel message", c), ie(c);
|
|
1291
1291
|
}
|
|
1292
1292
|
}
|
|
1293
1293
|
return {
|
|
@@ -1295,32 +1295,32 @@ async function An(e, t, { debug: r = !1, callbacks: a, auth: o, baseURL: s = Ee,
|
|
|
1295
1295
|
* Method to send request to server to get clip or talk depend on you payload
|
|
1296
1296
|
* @param payload
|
|
1297
1297
|
*/
|
|
1298
|
-
speak(
|
|
1299
|
-
return D(j, N,
|
|
1298
|
+
speak(y) {
|
|
1299
|
+
return D(j, N, y);
|
|
1300
1300
|
},
|
|
1301
1301
|
/**
|
|
1302
1302
|
* Method to close RTC connection
|
|
1303
1303
|
*/
|
|
1304
1304
|
async disconnect() {
|
|
1305
|
-
var
|
|
1305
|
+
var y;
|
|
1306
1306
|
if (j) {
|
|
1307
1307
|
const v = ot(T.iceConnectionState);
|
|
1308
1308
|
if (T) {
|
|
1309
|
-
if (v ===
|
|
1309
|
+
if (v === R.New) {
|
|
1310
1310
|
Y.stop();
|
|
1311
1311
|
return;
|
|
1312
1312
|
}
|
|
1313
1313
|
T.close(), T.oniceconnectionstatechange = null, T.onnegotiationneeded = null, T.onicecandidate = null, T.ontrack = null;
|
|
1314
1314
|
}
|
|
1315
1315
|
try {
|
|
1316
|
-
v ===
|
|
1316
|
+
v === R.Connected && await S(j, N);
|
|
1317
1317
|
} catch (c) {
|
|
1318
1318
|
n("Error on close stream connection", c);
|
|
1319
1319
|
}
|
|
1320
|
-
(
|
|
1320
|
+
(y = a.onAgentActivityStateChange) == null || y.call(a, we.Idle), Y.stop();
|
|
1321
1321
|
}
|
|
1322
1322
|
},
|
|
1323
|
-
sendDataChannelMessage:
|
|
1323
|
+
sendDataChannelMessage: le,
|
|
1324
1324
|
/**
|
|
1325
1325
|
* Session identifier information, should be returned in the body of all streaming requests
|
|
1326
1326
|
*/
|
|
@@ -1330,21 +1330,21 @@ async function An(e, t, { debug: r = !1, callbacks: a, auth: o, baseURL: s = Ee,
|
|
|
1330
1330
|
*/
|
|
1331
1331
|
streamId: j,
|
|
1332
1332
|
streamType: B,
|
|
1333
|
-
interruptAvailable:
|
|
1333
|
+
interruptAvailable: ye ?? !1,
|
|
1334
1334
|
isInterruptible: !0,
|
|
1335
|
-
interrupt(
|
|
1336
|
-
if (!
|
|
1335
|
+
interrupt(y) {
|
|
1336
|
+
if (!ye || B !== H.Fluent || !V || !h || G.readyState !== "open")
|
|
1337
1337
|
return !1;
|
|
1338
1338
|
const v = {
|
|
1339
1339
|
type: k.StreamInterrupt,
|
|
1340
1340
|
videoId: V,
|
|
1341
1341
|
timestamp: Date.now()
|
|
1342
1342
|
};
|
|
1343
|
-
return
|
|
1343
|
+
return le(Re.Interrupt, JSON.stringify(v)), !0;
|
|
1344
1344
|
}
|
|
1345
1345
|
};
|
|
1346
1346
|
}
|
|
1347
|
-
var
|
|
1347
|
+
var Ee = /* @__PURE__ */ ((e) => (e.V1 = "v1", e.V2 = "v2", e))(Ee || {});
|
|
1348
1348
|
async function Pn(e, t, r, a) {
|
|
1349
1349
|
const o = e.id;
|
|
1350
1350
|
switch (t.version) {
|
|
@@ -1356,7 +1356,7 @@ async function Pn(e, t, r, a) {
|
|
|
1356
1356
|
const { version: s, ...i } = t;
|
|
1357
1357
|
switch (i.transport.provider) {
|
|
1358
1358
|
case Fe.Livekit:
|
|
1359
|
-
const { createLiveKitStreamingManager: u } = await import("./livekit-manager-
|
|
1359
|
+
const { createLiveKitStreamingManager: u } = await import("./livekit-manager-CAbeu0Rj.js");
|
|
1360
1360
|
return u(o, i, r);
|
|
1361
1361
|
default:
|
|
1362
1362
|
throw new Error(`Unsupported transport provider: ${i.transport.provider}`);
|
|
@@ -1388,7 +1388,7 @@ function Ln(e) {
|
|
|
1388
1388
|
}, ...r && { end_user_data: r } };
|
|
1389
1389
|
}
|
|
1390
1390
|
function jn(e, t) {
|
|
1391
|
-
return Ve(e.avatar.type) ? { version:
|
|
1391
|
+
return Ve(e.avatar.type) ? { version: Ee.V2, ...xn(t) } : { version: Ee.V1, ...Ln(t) };
|
|
1392
1392
|
}
|
|
1393
1393
|
function Bn(e, t, r) {
|
|
1394
1394
|
r.track("agent-connection-state-change", { state: e, ...t && { reason: t } });
|
|
@@ -1438,14 +1438,14 @@ function zn(e, t, r) {
|
|
|
1438
1438
|
call_id: t.callId,
|
|
1439
1439
|
name: t.name
|
|
1440
1440
|
};
|
|
1441
|
-
if (e ===
|
|
1441
|
+
if (e === Be.Started) {
|
|
1442
1442
|
r.track("agent-tool-call", { ...a, event: "started" });
|
|
1443
1443
|
return;
|
|
1444
1444
|
}
|
|
1445
1445
|
const o = t;
|
|
1446
1446
|
r.track("agent-tool-call", {
|
|
1447
1447
|
...a,
|
|
1448
|
-
event: e ===
|
|
1448
|
+
event: e === Be.Done ? "done" : "error",
|
|
1449
1449
|
duration_ms: o.durationMs,
|
|
1450
1450
|
extra_keys: o.extra ? Object.keys(o.extra).length : 0
|
|
1451
1451
|
});
|
|
@@ -1459,7 +1459,7 @@ function ut(e, t, r, a) {
|
|
|
1459
1459
|
"stream-version": n.version.toString()
|
|
1460
1460
|
});
|
|
1461
1461
|
let d = null;
|
|
1462
|
-
const h =
|
|
1462
|
+
const h = n.version === Ee.V2;
|
|
1463
1463
|
i = await Pn(
|
|
1464
1464
|
e,
|
|
1465
1465
|
n,
|
|
@@ -1470,7 +1470,7 @@ function ut(e, t, r, a) {
|
|
|
1470
1470
|
...t.callbacks,
|
|
1471
1471
|
onConnectionStateChange: (f, g) => {
|
|
1472
1472
|
var l, p;
|
|
1473
|
-
(p = (l = t.callbacks).onConnectionStateChange) == null || p.call(l, f, g), Bn(f, g, r), f ===
|
|
1473
|
+
(p = (l = t.callbacks).onConnectionStateChange) == null || p.call(l, f, g), Bn(f, g, r), f === R.Connected && (i ? o(i) : u = !0);
|
|
1474
1474
|
},
|
|
1475
1475
|
onVideoStateChange: (f, g) => {
|
|
1476
1476
|
var l, p;
|
|
@@ -1484,7 +1484,7 @@ function ut(e, t, r, a) {
|
|
|
1484
1484
|
},
|
|
1485
1485
|
onAgentActivityStateChange: (f) => {
|
|
1486
1486
|
var g, l;
|
|
1487
|
-
(l = (g = t.callbacks).onAgentActivityStateChange) == null || l.call(g, f), f ===
|
|
1487
|
+
(l = (g = t.callbacks).onAgentActivityStateChange) == null || l.call(g, f), f === we.Talking ? (ze.update(), d = (p) => {
|
|
1488
1488
|
dt(
|
|
1489
1489
|
C.Start,
|
|
1490
1490
|
e,
|
|
@@ -1492,7 +1492,7 @@ function ut(e, t, r, a) {
|
|
|
1492
1492
|
i.streamType,
|
|
1493
1493
|
p
|
|
1494
1494
|
), d = null;
|
|
1495
|
-
}, h || d({ latency: K.get(!0) })) : (
|
|
1495
|
+
}, h || d({ latency: K.get(!0) })) : (ze.reset(), d = null, dt(
|
|
1496
1496
|
C.Stop,
|
|
1497
1497
|
e,
|
|
1498
1498
|
r,
|
|
@@ -1559,62 +1559,62 @@ async function Fn(e, t, r, a, o) {
|
|
|
1559
1559
|
}, { chatResult: i, streamingManager: u } = await s(), { chat: n, chatMode: d } = i;
|
|
1560
1560
|
return d && t.mode !== void 0 && d !== t.mode && d !== L.Functional ? ((f = (h = t.callbacks).onError) == null || f.call(h, new Bt(d)), u == null || u.disconnect(), { chat: n }) : { chat: n, streamingManager: u };
|
|
1561
1561
|
}
|
|
1562
|
-
const
|
|
1562
|
+
const je = "ChatMode.Off and ChatMode.DirectPlayback are not supported for Expressive agents", lt = "callbacks.onSrcObjectReady is required in every chat mode that streams video; it is optional only in ChatMode.TextOnly, ChatMode.Playground and ChatMode.Maintenance", Vn = [R.Disconnected, R.Closed, R.Fail];
|
|
1563
1563
|
async function Kn(e, t) {
|
|
1564
|
-
var
|
|
1564
|
+
var ue, le, fe, y, v;
|
|
1565
1565
|
const r = { ...t.callbacks };
|
|
1566
1566
|
let a = !0;
|
|
1567
|
-
const o = ((
|
|
1568
|
-
if (!r.onSrcObjectReady && !
|
|
1569
|
-
throw new
|
|
1567
|
+
const o = ((ue = t.analytics) == null ? void 0 : ue.mixpanelKey) || Lt, s = t.wsURL || xt, i = t.baseURL || ke, u = t.mode || L.Functional;
|
|
1568
|
+
if (!r.onSrcObjectReady && !Pe(u))
|
|
1569
|
+
throw new I(lt);
|
|
1570
1570
|
const n = {
|
|
1571
1571
|
messages: [],
|
|
1572
1572
|
chatMode: u
|
|
1573
1573
|
}, d = nn({
|
|
1574
1574
|
token: o,
|
|
1575
1575
|
agentId: e,
|
|
1576
|
-
isEnabled: (
|
|
1576
|
+
isEnabled: (le = t.analytics) == null ? void 0 : le.enabled,
|
|
1577
1577
|
externalId: t.externalId,
|
|
1578
|
-
mixpanelAdditionalProperties: (
|
|
1578
|
+
mixpanelAdditionalProperties: (fe = t.analytics) == null ? void 0 : fe.additionalProperties
|
|
1579
1579
|
}), h = Date.now();
|
|
1580
1580
|
nt(() => {
|
|
1581
1581
|
d.track("agent-sdk", { event: "init" }, h);
|
|
1582
1582
|
});
|
|
1583
|
-
let f =
|
|
1583
|
+
let f = R.New, g;
|
|
1584
1584
|
const l = {
|
|
1585
1585
|
...r,
|
|
1586
1586
|
onError(c, m) {
|
|
1587
|
-
var
|
|
1588
|
-
d.track("agent-error", { error:
|
|
1587
|
+
var w;
|
|
1588
|
+
d.track("agent-error", { error: xe(c) }), (w = r.onError) == null || w.call(r, c, m);
|
|
1589
1589
|
},
|
|
1590
1590
|
onConnectionStateChange(c, m) {
|
|
1591
|
-
var
|
|
1592
|
-
f = c, (
|
|
1591
|
+
var w;
|
|
1592
|
+
f = c, (w = r.onConnectionStateChange) == null || w.call(r, c, m);
|
|
1593
1593
|
},
|
|
1594
1594
|
onStreamCreated(c) {
|
|
1595
1595
|
var m;
|
|
1596
1596
|
g = c, (m = r.onStreamCreated) == null || m.call(r, c);
|
|
1597
1597
|
}
|
|
1598
1598
|
}, p = { ...t, callbacks: l }, D = Ht(p.auth, i, l.onError, p.externalId), S = await D.getRuntimeById(e);
|
|
1599
|
-
p.debug = p.debug || ((
|
|
1599
|
+
p.debug = p.debug || ((y = S == null ? void 0 : S.advanced_settings) == null ? void 0 : y.ui_debug_mode);
|
|
1600
1600
|
const P = Ve(S.avatar.type);
|
|
1601
1601
|
if (P && te(u))
|
|
1602
|
-
throw new
|
|
1603
|
-
P && import("./livekit-manager-
|
|
1602
|
+
throw new I(je);
|
|
1603
|
+
P && import("./livekit-manager-CAbeu0Rj.js").then(({ preloadLiveKit: c }) => c()).catch(() => {
|
|
1604
1604
|
}), d.enrich(Kt(S));
|
|
1605
1605
|
const { onMessage: U, clearQueue: j } = mn(d, n, p, S, (c) => {
|
|
1606
|
-
var m,
|
|
1607
|
-
(m = n.socketManager) == null || m.disconnect(), (
|
|
1606
|
+
var m, w;
|
|
1607
|
+
(m = n.socketManager) == null || m.disconnect(), (w = l.onConnectionStateChange) == null || w.call(l, R.Disconnected, c);
|
|
1608
1608
|
});
|
|
1609
1609
|
n.messages = rn(p.initialMessages), n.messages.length && ((v = l.onNewMessage) == null || v.call(l, [...n.messages], "answer"));
|
|
1610
|
-
const
|
|
1610
|
+
const re = (c) => d.enrich({ videoId: c }), ae = (c) => {
|
|
1611
1611
|
var O;
|
|
1612
|
-
const m = (c == null ? void 0 : c.type) ?? "click",
|
|
1613
|
-
if (!(
|
|
1612
|
+
const m = (c == null ? void 0 : c.type) ?? "click", w = n.streamingManager;
|
|
1613
|
+
if (!(w != null && w.interruptAvailable) || !w.isInterruptible || !w.interrupt(m))
|
|
1614
1614
|
return;
|
|
1615
1615
|
d.track("agent-video-interrupt", {
|
|
1616
1616
|
type: m,
|
|
1617
|
-
video_duration_to_interrupt:
|
|
1617
|
+
video_duration_to_interrupt: ze.get(!0),
|
|
1618
1618
|
message_duration_to_interrupt: K.get(!0)
|
|
1619
1619
|
});
|
|
1620
1620
|
const E = n.messages[n.messages.length - 1];
|
|
@@ -1622,28 +1622,28 @@ async function Kn(e, t) {
|
|
|
1622
1622
|
}, N = /* @__PURE__ */ new Map();
|
|
1623
1623
|
function ee(c) {
|
|
1624
1624
|
return async (m) => {
|
|
1625
|
-
const
|
|
1626
|
-
if (!
|
|
1625
|
+
const w = N.get(c);
|
|
1626
|
+
if (!w)
|
|
1627
1627
|
throw new Error(`No handler registered for client tool: ${c}`);
|
|
1628
1628
|
const M = JSON.parse(m.payload);
|
|
1629
|
-
return
|
|
1629
|
+
return w(M);
|
|
1630
1630
|
};
|
|
1631
1631
|
}
|
|
1632
|
-
function
|
|
1633
|
-
var c, m,
|
|
1632
|
+
function ye() {
|
|
1633
|
+
var c, m, w, M;
|
|
1634
1634
|
for (const [E] of N)
|
|
1635
|
-
(m = (c = n.streamingManager) == null ? void 0 : c.unregisterRpcMethod) == null || m.call(c, E), (M = (
|
|
1635
|
+
(m = (c = n.streamingManager) == null ? void 0 : c.unregisterRpcMethod) == null || m.call(c, E), (M = (w = n.streamingManager) == null ? void 0 : w.registerRpcMethod) == null || M.call(w, E, ee(E));
|
|
1636
1636
|
}
|
|
1637
|
-
function
|
|
1637
|
+
function ie(c, m) {
|
|
1638
1638
|
var M, E;
|
|
1639
1639
|
if (!P)
|
|
1640
|
-
throw new
|
|
1641
|
-
const
|
|
1642
|
-
N.set(c, m),
|
|
1640
|
+
throw new I("registerClientTool is only available on Expressive (V4) agents");
|
|
1641
|
+
const w = !N.has(c);
|
|
1642
|
+
N.set(c, m), w && ((E = (M = n.streamingManager) == null ? void 0 : M.registerRpcMethod) == null || E.call(M, c, ee(c)));
|
|
1643
1643
|
}
|
|
1644
1644
|
function T(c) {
|
|
1645
|
-
var m,
|
|
1646
|
-
N.delete(c), (
|
|
1645
|
+
var m, w;
|
|
1646
|
+
N.delete(c), (w = (m = n.streamingManager) == null ? void 0 : m.unregisterRpcMethod) == null || w.call(m, c);
|
|
1647
1647
|
}
|
|
1648
1648
|
const G = Date.now();
|
|
1649
1649
|
nt(() => {
|
|
@@ -1655,20 +1655,20 @@ async function Kn(e, t) {
|
|
|
1655
1655
|
B = void 0;
|
|
1656
1656
|
}), B;
|
|
1657
1657
|
}
|
|
1658
|
-
function
|
|
1658
|
+
function se(c) {
|
|
1659
1659
|
return B || ve(() => Y(c));
|
|
1660
1660
|
}
|
|
1661
1661
|
async function Y(c) {
|
|
1662
|
-
var J,
|
|
1662
|
+
var J, Te, _e, $;
|
|
1663
1663
|
if (X)
|
|
1664
1664
|
return;
|
|
1665
|
-
n.streamingManager && await V(), At(), (J = l.onConnectionStateChange) == null || J.call(l,
|
|
1666
|
-
const m =
|
|
1665
|
+
n.streamingManager && await V(), At(), (J = l.onConnectionStateChange) == null || J.call(l, R.Connecting), K.reset(), c && !a && (delete n.chat, (Te = l.onNewMessage) == null || Te.call(l, [...n.messages], "answer"));
|
|
1666
|
+
const m = oe(n.chatMode) ? on(
|
|
1667
1667
|
p.auth,
|
|
1668
1668
|
s,
|
|
1669
1669
|
{ onMessage: U, onError: l.onError },
|
|
1670
1670
|
p.externalId
|
|
1671
|
-
) : Promise.resolve(void 0),
|
|
1671
|
+
) : Promise.resolve(void 0), w = Ne(
|
|
1672
1672
|
() => Fn(
|
|
1673
1673
|
S,
|
|
1674
1674
|
{
|
|
@@ -1676,7 +1676,7 @@ async function Kn(e, t) {
|
|
|
1676
1676
|
mode: n.chatMode,
|
|
1677
1677
|
callbacks: {
|
|
1678
1678
|
...l,
|
|
1679
|
-
onVideoIdChange:
|
|
1679
|
+
onVideoIdChange: re,
|
|
1680
1680
|
onMessage: U
|
|
1681
1681
|
},
|
|
1682
1682
|
rpcMethods: new Map([...N.keys()].map((z) => [z, ee(z)]))
|
|
@@ -1695,47 +1695,47 @@ async function Kn(e, t) {
|
|
|
1695
1695
|
).catch(async (z) => {
|
|
1696
1696
|
var Ce;
|
|
1697
1697
|
throw m.then((W) => W == null ? void 0 : W.disconnect()).catch(() => {
|
|
1698
|
-
}), await
|
|
1699
|
-
}), M = (
|
|
1698
|
+
}), await ce(L.Maintenance), (Ce = l.onConnectionStateChange) == null || Ce.call(l, R.Fail), z;
|
|
1699
|
+
}), M = (_e = n.chat) == null ? void 0 : _e.id, [E, { streamingManager: O, chat: _ }] = await Promise.all([m, w]), b = !!_ && _.id !== M;
|
|
1700
1700
|
if (_ && b && (($ = l.onNewChat) == null || $.call(l, _.id)), n.streamingManager = O, n.socketManager = E, n.chat = _, X) {
|
|
1701
1701
|
await V();
|
|
1702
1702
|
return;
|
|
1703
1703
|
}
|
|
1704
|
-
|
|
1704
|
+
ye(), a = !1, d.enrich({
|
|
1705
1705
|
chatId: _ == null ? void 0 : _.id,
|
|
1706
1706
|
streamId: O == null ? void 0 : O.streamId,
|
|
1707
1707
|
mode: n.chatMode
|
|
1708
1708
|
});
|
|
1709
1709
|
const A = (b ? _ == null ? void 0 : _.chat_mode : void 0) ?? n.chatMode;
|
|
1710
1710
|
if (P && te(A)) {
|
|
1711
|
-
console.warn(`[AgentManager] Ignoring chat mode "${A}": ${
|
|
1711
|
+
console.warn(`[AgentManager] Ignoring chat mode "${A}": ${je}`);
|
|
1712
1712
|
return;
|
|
1713
1713
|
}
|
|
1714
|
-
await
|
|
1714
|
+
await ce(A);
|
|
1715
1715
|
}
|
|
1716
1716
|
async function V() {
|
|
1717
|
-
var c, m,
|
|
1718
|
-
(c = n.socketManager) == null || c.disconnect(), await ((m = n.streamingManager) == null ? void 0 : m.disconnect()), delete n.streamingManager, delete n.socketManager, g = void 0, (
|
|
1717
|
+
var c, m, w;
|
|
1718
|
+
(c = n.socketManager) == null || c.disconnect(), await ((m = n.streamingManager) == null ? void 0 : m.disconnect()), delete n.streamingManager, delete n.socketManager, g = void 0, (w = l.onConnectionStateChange) == null || w.call(l, R.Disconnected);
|
|
1719
1719
|
}
|
|
1720
|
-
function
|
|
1720
|
+
function oe(c) {
|
|
1721
1721
|
return !P && c !== L.DirectPlayback;
|
|
1722
1722
|
}
|
|
1723
1723
|
function Se(c) {
|
|
1724
1724
|
const m = !te(c);
|
|
1725
|
-
return (!
|
|
1725
|
+
return (!oe(c) || !!n.socketManager) && (!m || !!n.chat);
|
|
1726
1726
|
}
|
|
1727
|
-
async function
|
|
1727
|
+
async function ce(c) {
|
|
1728
1728
|
var m;
|
|
1729
1729
|
if (c !== n.chatMode) {
|
|
1730
1730
|
d.track("agent-mode-change", { mode: c }), n.chatMode = c;
|
|
1731
|
-
const
|
|
1732
|
-
(c !== L.Functional ||
|
|
1731
|
+
const w = !!n.streamingManager || !!n.socketManager;
|
|
1732
|
+
(c !== L.Functional || w && !Se(c)) && await V(), (m = l.onModeChange) == null || m.call(l, c);
|
|
1733
1733
|
}
|
|
1734
1734
|
}
|
|
1735
|
-
async function
|
|
1735
|
+
async function de(c) {
|
|
1736
1736
|
if (P && te(c))
|
|
1737
|
-
throw new
|
|
1738
|
-
await
|
|
1737
|
+
throw new I(je);
|
|
1738
|
+
await ce(c);
|
|
1739
1739
|
}
|
|
1740
1740
|
return {
|
|
1741
1741
|
agent: S,
|
|
@@ -1754,31 +1754,31 @@ async function Kn(e, t) {
|
|
|
1754
1754
|
getChatMode: () => n.chatMode,
|
|
1755
1755
|
getConnectionState: () => f,
|
|
1756
1756
|
getSessionInfo: () => g,
|
|
1757
|
-
changeMode:
|
|
1757
|
+
changeMode: de,
|
|
1758
1758
|
enrichAnalytics: (c) => d.enrich(c),
|
|
1759
1759
|
async connect() {
|
|
1760
|
-
if (!l.onSrcObjectReady && !
|
|
1761
|
-
throw new
|
|
1760
|
+
if (!l.onSrcObjectReady && !Pe(n.chatMode))
|
|
1761
|
+
throw new I(lt);
|
|
1762
1762
|
if (B)
|
|
1763
1763
|
return X = !1, B;
|
|
1764
1764
|
if (n.streamingManager && !Vn.includes(f))
|
|
1765
|
-
throw new
|
|
1766
|
-
await
|
|
1765
|
+
throw new I("Already connected; call disconnect() first");
|
|
1766
|
+
await se(!0), n.streamingManager && d.track("agent-chat", {
|
|
1767
1767
|
event: "connect",
|
|
1768
1768
|
mode: n.chatMode
|
|
1769
1769
|
});
|
|
1770
1770
|
},
|
|
1771
1771
|
async reconnect() {
|
|
1772
1772
|
if (B)
|
|
1773
|
-
throw new
|
|
1773
|
+
throw new I("A connect() is in flight; wait for it before calling reconnect()");
|
|
1774
1774
|
return ve(async () => {
|
|
1775
1775
|
const c = n.streamingManager;
|
|
1776
1776
|
let m;
|
|
1777
1777
|
if (P && (c != null && c.reconnect))
|
|
1778
1778
|
try {
|
|
1779
1779
|
await c.reconnect();
|
|
1780
|
-
} catch (
|
|
1781
|
-
const M =
|
|
1780
|
+
} catch (w) {
|
|
1781
|
+
const M = xe(w);
|
|
1782
1782
|
m = M.code ?? M.kind, await V(), await Y(!1);
|
|
1783
1783
|
}
|
|
1784
1784
|
else
|
|
@@ -1802,22 +1802,22 @@ async function Kn(e, t) {
|
|
|
1802
1802
|
publishMicrophoneStream(c) {
|
|
1803
1803
|
var m;
|
|
1804
1804
|
return (m = n.streamingManager) != null && m.publishMicrophoneStream ? n.streamingManager.publishMicrophoneStream(c) : Promise.reject(
|
|
1805
|
-
new
|
|
1805
|
+
new I(
|
|
1806
1806
|
"publishMicrophoneStream is only available on Expressive (V4) agents, after connect()"
|
|
1807
1807
|
)
|
|
1808
1808
|
);
|
|
1809
1809
|
},
|
|
1810
1810
|
setSttLanguage(c) {
|
|
1811
1811
|
return !P || !n.streamingManager ? Promise.reject(
|
|
1812
|
-
new
|
|
1812
|
+
new I("setSttLanguage is only available on Expressive (V4) agents, after connect()")
|
|
1813
1813
|
) : (d.track("agent-stt-language-change", { language: c }), n.streamingManager.sendDataChannelMessage(
|
|
1814
|
-
|
|
1814
|
+
Re.SttLanguage,
|
|
1815
1815
|
JSON.stringify({ language: c })
|
|
1816
1816
|
));
|
|
1817
1817
|
},
|
|
1818
1818
|
sendDataChannelMessage(c, m) {
|
|
1819
1819
|
return !P || !n.streamingManager ? Promise.reject(
|
|
1820
|
-
new
|
|
1820
|
+
new I(
|
|
1821
1821
|
"sendDataChannelMessage is only available on Expressive (V4) agents, after connect()"
|
|
1822
1822
|
)
|
|
1823
1823
|
) : (d.track("agent-data-message", { topic: c }), n.streamingManager.sendDataChannelMessage(c, JSON.stringify(m)));
|
|
@@ -1829,7 +1829,7 @@ async function Kn(e, t) {
|
|
|
1829
1829
|
replaceMicrophoneTrack(c) {
|
|
1830
1830
|
var m;
|
|
1831
1831
|
return (m = n.streamingManager) != null && m.replaceMicrophoneTrack ? n.streamingManager.replaceMicrophoneTrack(c) : Promise.reject(
|
|
1832
|
-
new
|
|
1832
|
+
new I(
|
|
1833
1833
|
"replaceMicrophoneTrack is only available on Expressive (V4) agents, after connect()"
|
|
1834
1834
|
)
|
|
1835
1835
|
);
|
|
@@ -1837,7 +1837,7 @@ async function Kn(e, t) {
|
|
|
1837
1837
|
publishCameraStream(c) {
|
|
1838
1838
|
var m;
|
|
1839
1839
|
return (m = n.streamingManager) != null && m.publishCameraStream ? n.streamingManager.publishCameraStream(c) : Promise.reject(
|
|
1840
|
-
new
|
|
1840
|
+
new I(
|
|
1841
1841
|
"publishCameraStream is only available on Expressive (V4) agents, after connect()"
|
|
1842
1842
|
)
|
|
1843
1843
|
);
|
|
@@ -1850,20 +1850,20 @@ async function Kn(e, t) {
|
|
|
1850
1850
|
var E, O, _;
|
|
1851
1851
|
const m = () => {
|
|
1852
1852
|
if (te(n.chatMode))
|
|
1853
|
-
throw new
|
|
1853
|
+
throw new I(`${n.chatMode} is enabled, chat is disabled`);
|
|
1854
1854
|
if (c.length >= He)
|
|
1855
|
-
throw new
|
|
1855
|
+
throw new I(`Message cannot be more than ${He} characters`);
|
|
1856
1856
|
if (c.length === 0)
|
|
1857
|
-
throw new
|
|
1857
|
+
throw new I("Message cannot be empty");
|
|
1858
1858
|
if (n.chatMode === L.Maintenance)
|
|
1859
|
-
throw new
|
|
1859
|
+
throw new I("Chat is in maintenance mode");
|
|
1860
1860
|
if (![L.TextOnly, L.Playground].includes(n.chatMode)) {
|
|
1861
1861
|
if (!n.streamingManager)
|
|
1862
|
-
throw new
|
|
1862
|
+
throw new I("Streaming manager is not initialized");
|
|
1863
1863
|
if (!n.chat)
|
|
1864
|
-
throw new
|
|
1864
|
+
throw new I("Chat is not initialized");
|
|
1865
1865
|
}
|
|
1866
|
-
},
|
|
1866
|
+
}, w = async () => {
|
|
1867
1867
|
var b;
|
|
1868
1868
|
if (!n.chat) {
|
|
1869
1869
|
const A = await Dt(
|
|
@@ -1880,10 +1880,10 @@ async function Kn(e, t) {
|
|
|
1880
1880
|
return n.chat.id;
|
|
1881
1881
|
}, M = async (b, A) => {
|
|
1882
1882
|
const J = n.chatMode === L.Playground;
|
|
1883
|
-
return
|
|
1883
|
+
return Ne(P && !J ? async () => {
|
|
1884
1884
|
var $;
|
|
1885
1885
|
return await (($ = n.streamingManager) == null ? void 0 : $.sendDataChannelMessage(
|
|
1886
|
-
|
|
1886
|
+
Re.Chat,
|
|
1887
1887
|
c
|
|
1888
1888
|
)), Promise.resolve({});
|
|
1889
1889
|
} : async () => {
|
|
@@ -1914,7 +1914,7 @@ async function Kn(e, t) {
|
|
|
1914
1914
|
return !((Me = $ == null ? void 0 : $.message) == null ? void 0 : Me.includes("Stream Error")) && !z ? ((Je = l.onError) == null || Je.call(l, $), !1) : !0;
|
|
1915
1915
|
},
|
|
1916
1916
|
onRetry: async () => {
|
|
1917
|
-
await V(), await
|
|
1917
|
+
await V(), await se(!1);
|
|
1918
1918
|
}
|
|
1919
1919
|
});
|
|
1920
1920
|
};
|
|
@@ -1923,15 +1923,15 @@ async function Kn(e, t) {
|
|
|
1923
1923
|
id: Z(),
|
|
1924
1924
|
role: "user",
|
|
1925
1925
|
content: c,
|
|
1926
|
-
parts:
|
|
1926
|
+
parts: pe(c),
|
|
1927
1927
|
createdAt: new Date(K.update()).toISOString()
|
|
1928
1928
|
}), (E = l.onNewMessage) == null || E.call(l, [...n.messages], "user");
|
|
1929
|
-
const b = await
|
|
1929
|
+
const b = await w(), A = await M([...n.messages], b);
|
|
1930
1930
|
return A.result && n.messages.push({
|
|
1931
1931
|
id: Z(),
|
|
1932
1932
|
role: "assistant",
|
|
1933
1933
|
content: A.result,
|
|
1934
|
-
parts:
|
|
1934
|
+
parts: pe(A.result),
|
|
1935
1935
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1936
1936
|
context: A.context,
|
|
1937
1937
|
matches: A.matches
|
|
@@ -1946,25 +1946,25 @@ async function Kn(e, t) {
|
|
|
1946
1946
|
throw ((_ = n.messages[n.messages.length - 1]) == null ? void 0 : _.role) === "assistant" && n.messages.pop(), d.track("agent-message-send", {
|
|
1947
1947
|
event: "error",
|
|
1948
1948
|
messages: n.messages.length,
|
|
1949
|
-
error:
|
|
1949
|
+
error: xe(b)
|
|
1950
1950
|
}), b;
|
|
1951
1951
|
}
|
|
1952
1952
|
},
|
|
1953
|
-
async rate(c, m,
|
|
1953
|
+
async rate(c, m, w) {
|
|
1954
1954
|
var O, _, b, A;
|
|
1955
1955
|
const M = n.messages.find((J) => J.id === c);
|
|
1956
1956
|
if (n.chat) {
|
|
1957
1957
|
if (!M)
|
|
1958
|
-
throw new
|
|
1959
|
-
} else throw new
|
|
1958
|
+
throw new I("Message not found");
|
|
1959
|
+
} else throw new I("Chat is not initialized");
|
|
1960
1960
|
const E = ((O = M.matches) == null ? void 0 : O.map((J) => [J.document_id, J.id])) ?? [];
|
|
1961
1961
|
return d.track("agent-rate", {
|
|
1962
|
-
event:
|
|
1962
|
+
event: w ? "update" : "create",
|
|
1963
1963
|
thumb: m === 1 ? "up" : "down",
|
|
1964
1964
|
knowledge_id: ((_ = S.knowledge) == null ? void 0 : _.id) ?? "",
|
|
1965
1965
|
matches: E,
|
|
1966
1966
|
score: m
|
|
1967
|
-
}),
|
|
1967
|
+
}), w ? D.updateRating(S.id, n.chat.id, w, {
|
|
1968
1968
|
knowledge_id: ((b = S.knowledge) == null ? void 0 : b.id) ?? "",
|
|
1969
1969
|
message_id: c,
|
|
1970
1970
|
matches: E,
|
|
@@ -1978,12 +1978,12 @@ async function Kn(e, t) {
|
|
|
1978
1978
|
},
|
|
1979
1979
|
async deleteRate(c) {
|
|
1980
1980
|
if (!n.chat)
|
|
1981
|
-
throw new
|
|
1981
|
+
throw new I("Chat is not initialized");
|
|
1982
1982
|
return d.track("agent-rate-delete", { type: "text" }), D.deleteRating(S.id, n.chat.id, c);
|
|
1983
1983
|
},
|
|
1984
1984
|
async submitFeedback(c, m) {
|
|
1985
1985
|
if (!n.chat)
|
|
1986
|
-
throw new
|
|
1986
|
+
throw new I("Chat is not initialized");
|
|
1987
1987
|
return d.track("agent-feedback", { rating: c, hasAnswer: !!m }), D.submitFeedback(S.id, n.chat.id, { rating: c, answer: m });
|
|
1988
1988
|
},
|
|
1989
1989
|
async speak(c) {
|
|
@@ -2001,25 +2001,25 @@ async function Kn(e, t) {
|
|
|
2001
2001
|
sentiment: c.sentiment
|
|
2002
2002
|
} : c;
|
|
2003
2003
|
}
|
|
2004
|
-
const
|
|
2005
|
-
if (!
|
|
2006
|
-
throw new
|
|
2004
|
+
const w = Pe(n.chatMode);
|
|
2005
|
+
if (!w && !n.streamingManager)
|
|
2006
|
+
throw new I("Please connect to the agent first");
|
|
2007
2007
|
const M = m();
|
|
2008
2008
|
d.track("agent-speak", M), K.update(), n.messages && M.type === "text" && (n.messages.push({
|
|
2009
2009
|
id: Z(),
|
|
2010
2010
|
role: "assistant",
|
|
2011
2011
|
content: M.input,
|
|
2012
|
-
parts:
|
|
2012
|
+
parts: pe(M.input),
|
|
2013
2013
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2014
2014
|
}), (_ = l.onNewMessage) == null || _.call(l, [...n.messages], "answer"));
|
|
2015
2015
|
const E = { duration: 0, videoId: "", status: "success" };
|
|
2016
|
-
return
|
|
2016
|
+
return w || !n.streamingManager ? E : await n.streamingManager.speak({
|
|
2017
2017
|
script: M,
|
|
2018
2018
|
metadata: { chat_id: (b = n.chat) == null ? void 0 : b.id, agent_id: S.id }
|
|
2019
2019
|
}) ?? E;
|
|
2020
2020
|
},
|
|
2021
|
-
interrupt:
|
|
2022
|
-
registerClientTool:
|
|
2021
|
+
interrupt: ae,
|
|
2022
|
+
registerClientTool: ie,
|
|
2023
2023
|
unregisterClientTool: T
|
|
2024
2024
|
};
|
|
2025
2025
|
}
|
|
@@ -2027,40 +2027,40 @@ function qn(e) {
|
|
|
2027
2027
|
return e.some((t) => t.executionMode === "blocking");
|
|
2028
2028
|
}
|
|
2029
2029
|
export {
|
|
2030
|
-
|
|
2030
|
+
we as A,
|
|
2031
2031
|
q as B,
|
|
2032
2032
|
F as C,
|
|
2033
2033
|
kt as D,
|
|
2034
2034
|
ht as H,
|
|
2035
|
-
|
|
2035
|
+
Re as I,
|
|
2036
2036
|
Nt as N,
|
|
2037
2037
|
Tt as P,
|
|
2038
2038
|
k as S,
|
|
2039
|
-
|
|
2040
|
-
|
|
2039
|
+
Be as T,
|
|
2040
|
+
I as V,
|
|
2041
2041
|
Ot as W,
|
|
2042
2042
|
hn as a,
|
|
2043
2043
|
H as b,
|
|
2044
2044
|
vt as c,
|
|
2045
|
-
|
|
2045
|
+
ke as d,
|
|
2046
2046
|
pt as e,
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2047
|
+
R as f,
|
|
2048
|
+
ge as g,
|
|
2049
|
+
Rn as h,
|
|
2050
2050
|
Wn as i,
|
|
2051
2051
|
C as j,
|
|
2052
|
-
|
|
2052
|
+
ne as k,
|
|
2053
2053
|
K as l,
|
|
2054
2054
|
jt as m,
|
|
2055
2055
|
Jn as n,
|
|
2056
2056
|
L as o,
|
|
2057
2057
|
Bt as p,
|
|
2058
|
-
|
|
2058
|
+
he as q,
|
|
2059
2059
|
_t as r,
|
|
2060
2060
|
Kn as s,
|
|
2061
|
-
|
|
2061
|
+
xe as t,
|
|
2062
2062
|
qn as u,
|
|
2063
2063
|
Hn as v,
|
|
2064
|
-
|
|
2064
|
+
yt as w
|
|
2065
2065
|
};
|
|
2066
|
-
//# sourceMappingURL=index-
|
|
2066
|
+
//# sourceMappingURL=index-D_aN1Y2k.js.map
|