@d-id/client-sdk 1.1.68-staging.322 → 1.1.68-staging.324
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-DmShldpU.js → index-7rYIrmzU.js} +179 -176
- package/dist/index.js +1 -1
- package/dist/index.umd.cjs +6 -6
- package/dist/{livekit-client.esm-RGXA_gNu.js → livekit-client.esm-DypJ_fOm.js} +97 -72
- package/dist/{livekit-manager-Zdv-HZDQ.js → livekit-manager-_ObM1JYd.js} +2 -2
- package/package.json +2 -2
|
@@ -35,7 +35,7 @@ class Xe extends ce {
|
|
|
35
35
|
super({ kind: "WSError", description: t });
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
var Ye = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(Ye || {}), Ge = /* @__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))(Ge || {}), Qe = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(Qe || {}), Ze = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(Ze || {}), x = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e.Off = "Off", e))(x || {}),
|
|
38
|
+
var Ye = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(Ye || {}), Ge = /* @__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))(Ge || {}), Qe = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(Qe || {}), Ze = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(Ze || {}), x = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e.Off = "Off", e))(x || {}), z = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Transcribe = "transcribe", e.Complete = "done", e))(z || {}), et = /* @__PURE__ */ ((e) => (e.KnowledgeProcessing = "knowledge/processing", e.KnowledgeIndexing = "knowledge/indexing", e.KnowledgeFailed = "knowledge/error", e.KnowledgeDone = "knowledge/done", e))(et || {}), tt = /* @__PURE__ */ ((e) => (e.Knowledge = "knowledge", e.Document = "document", e.Record = "record", e))(tt || {}), rt = /* @__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))(rt || {}), je = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e.Expressive = "expressive", e))(je || {});
|
|
39
39
|
const sr = (e) => {
|
|
40
40
|
switch (e) {
|
|
41
41
|
case "clip":
|
|
@@ -376,7 +376,7 @@ function we() {
|
|
|
376
376
|
get: (t = !1) => t ? Date.now() - e : e
|
|
377
377
|
};
|
|
378
378
|
}
|
|
379
|
-
const H = we(), fe = we(),
|
|
379
|
+
const H = we(), fe = we(), _e = we();
|
|
380
380
|
function Ve(e) {
|
|
381
381
|
return e === x.Playground ? { headers: { [st]: "true" } } : {};
|
|
382
382
|
}
|
|
@@ -405,14 +405,14 @@ function Mt(e) {
|
|
|
405
405
|
function Et(e) {
|
|
406
406
|
return new Promise((t, r) => {
|
|
407
407
|
const { callbacks: a, host: c, auth: s, externalId: o } = e, { onMessage: n = null, onOpen: i = null, onClose: d = null, onError: m = null } = a || {}, l = new WebSocket(`${c}?authorization=${encodeURIComponent(Fe(s, o))}`);
|
|
408
|
-
l.onmessage = n, l.onclose = d, l.onerror = (
|
|
409
|
-
console.error(
|
|
410
|
-
}, l.onopen = (
|
|
411
|
-
i == null || i(
|
|
408
|
+
l.onmessage = n, l.onclose = d, l.onerror = (w) => {
|
|
409
|
+
console.error(w), m == null || m("Websocket failed to connect", w), r(w);
|
|
410
|
+
}, l.onopen = (w) => {
|
|
411
|
+
i == null || i(w), t(l);
|
|
412
412
|
};
|
|
413
413
|
});
|
|
414
414
|
}
|
|
415
|
-
async function
|
|
415
|
+
async function _t(e) {
|
|
416
416
|
const { retries: t = 1 } = e;
|
|
417
417
|
let r = null;
|
|
418
418
|
for (let a = 0; (r == null ? void 0 : r.readyState) !== WebSocket.OPEN; a++)
|
|
@@ -425,8 +425,8 @@ async function Tt(e) {
|
|
|
425
425
|
}
|
|
426
426
|
return r;
|
|
427
427
|
}
|
|
428
|
-
async function
|
|
429
|
-
const c = r != null && r.onMessage ? [r.onMessage] : [], s = await
|
|
428
|
+
async function Tt(e, t, r, a) {
|
|
429
|
+
const c = r != null && r.onMessage ? [r.onMessage] : [], s = await _t({
|
|
430
430
|
auth: e,
|
|
431
431
|
host: t,
|
|
432
432
|
externalId: a,
|
|
@@ -447,7 +447,7 @@ async function _t(e, t, r, a) {
|
|
|
447
447
|
subscribeToEvents: (o) => c.push(o)
|
|
448
448
|
};
|
|
449
449
|
}
|
|
450
|
-
function
|
|
450
|
+
function Te(e) {
|
|
451
451
|
if (e.answer !== void 0)
|
|
452
452
|
return e.answer;
|
|
453
453
|
let t = 0, r = "";
|
|
@@ -455,7 +455,7 @@ function _e(e) {
|
|
|
455
455
|
r += e[t++];
|
|
456
456
|
return r;
|
|
457
457
|
}
|
|
458
|
-
function
|
|
458
|
+
function At(e, t, r) {
|
|
459
459
|
if (!e.content)
|
|
460
460
|
return;
|
|
461
461
|
const a = {
|
|
@@ -468,36 +468,39 @@ function bt(e, t, r) {
|
|
|
468
468
|
};
|
|
469
469
|
t.messages.push(a), r == null || r([...t.messages], "user");
|
|
470
470
|
}
|
|
471
|
-
function
|
|
472
|
-
if (e ===
|
|
473
|
-
|
|
471
|
+
function bt(e, t, r, a, c, s, o) {
|
|
472
|
+
if (e === z.Transcribe && t.content) {
|
|
473
|
+
At(t, a, c);
|
|
474
474
|
return;
|
|
475
475
|
}
|
|
476
|
-
if (!(e ===
|
|
476
|
+
if (!(e === z.Partial || e === z.Answer))
|
|
477
477
|
return;
|
|
478
|
-
const n = a.messages[a.messages.length - 1]
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
478
|
+
const n = a.messages[a.messages.length - 1];
|
|
479
|
+
if (e === z.Answer && (n == null ? void 0 : n.role) === "user" && o === "partial")
|
|
480
|
+
return;
|
|
481
|
+
const d = o === "answer";
|
|
482
|
+
let m;
|
|
483
|
+
if ((n == null ? void 0 : n.role) === "assistant" && !d)
|
|
484
|
+
m = n;
|
|
485
|
+
else if (!n || n.role === "user" || d)
|
|
486
|
+
d && s(), m = {
|
|
484
487
|
id: t.id || `assistant-${Date.now()}`,
|
|
485
488
|
role: t.role || "assistant",
|
|
486
489
|
content: t.content || "",
|
|
487
490
|
parts: [],
|
|
488
491
|
created_at: t.created_at || (/* @__PURE__ */ new Date()).toISOString()
|
|
489
|
-
}, a.messages.push(
|
|
492
|
+
}, a.messages.push(m);
|
|
490
493
|
else
|
|
491
494
|
return;
|
|
492
|
-
const { content:
|
|
493
|
-
if (e ===
|
|
494
|
-
r[
|
|
495
|
+
const { content: l, sequence: w } = t;
|
|
496
|
+
if (e === z.Partial)
|
|
497
|
+
r[w] = l;
|
|
495
498
|
else {
|
|
496
|
-
const
|
|
497
|
-
!!(
|
|
499
|
+
const y = Te(r);
|
|
500
|
+
!!(l && l.length < y.length) && (m.interrupted = !0), r.answer = l;
|
|
498
501
|
}
|
|
499
|
-
const p =
|
|
500
|
-
(
|
|
502
|
+
const p = Te(r);
|
|
503
|
+
(m.content !== p || e === z.Answer) && (m.content = p, m.parts = re(p), c == null || c([...a.messages], e));
|
|
501
504
|
}
|
|
502
505
|
function xt(e, t, r, a, c) {
|
|
503
506
|
const s = {}, o = () => {
|
|
@@ -506,42 +509,42 @@ function xt(e, t, r, a, c) {
|
|
|
506
509
|
};
|
|
507
510
|
let n = null;
|
|
508
511
|
const i = (d, m) => {
|
|
509
|
-
var l,
|
|
510
|
-
m === "user" && o(), (
|
|
512
|
+
var l, w;
|
|
513
|
+
m === "user" && o(), (w = (l = r.callbacks).onNewMessage) == null || w.call(l, d, m);
|
|
511
514
|
};
|
|
512
515
|
return {
|
|
513
516
|
clearQueue: o,
|
|
514
517
|
onMessage: (d, m) => {
|
|
515
|
-
var l,
|
|
518
|
+
var l, w;
|
|
516
519
|
if ("content" in m) {
|
|
517
|
-
const
|
|
518
|
-
|
|
519
|
-
|
|
520
|
+
const p = d === P.ChatAnswer ? z.Answer : d === P.ChatAudioTranscribed ? z.Transcribe : d;
|
|
521
|
+
bt(
|
|
522
|
+
p,
|
|
520
523
|
m,
|
|
521
524
|
s,
|
|
522
525
|
t,
|
|
523
526
|
i,
|
|
524
527
|
o,
|
|
525
528
|
n
|
|
526
|
-
),
|
|
529
|
+
), p === z.Partial ? n = "partial" : p === z.Answer && (n = "answer", o()), p === z.Answer && e.track("agent-message-received", {
|
|
527
530
|
content: m.content,
|
|
528
531
|
messages: t.messages.length,
|
|
529
532
|
mode: t.chatMode
|
|
530
533
|
});
|
|
531
534
|
} else {
|
|
532
|
-
const
|
|
533
|
-
if (d = d, d ===
|
|
535
|
+
const p = P, y = [p.StreamVideoDone, p.StreamVideoError, p.StreamVideoRejected], B = [p.StreamFailed, p.StreamVideoError, p.StreamVideoRejected], M = kt(m, a, { mode: t.chatMode });
|
|
536
|
+
if (d = d, d === p.StreamVideoCreated && (e.linkTrack("agent-video", M, p.StreamVideoCreated, ["start"]), m.sentiment)) {
|
|
534
537
|
const D = t.messages[t.messages.length - 1];
|
|
535
538
|
if ((D == null ? void 0 : D.role) === "assistant") {
|
|
536
539
|
const $ = { ...D, sentiment: m.sentiment };
|
|
537
540
|
t.messages[t.messages.length - 1] = $, i == null || i([...t.messages], n ?? "answer");
|
|
538
541
|
}
|
|
539
542
|
}
|
|
540
|
-
if (
|
|
543
|
+
if (y.includes(d)) {
|
|
541
544
|
const D = d.split("/")[1];
|
|
542
545
|
B.includes(d) ? e.track("agent-video", { ...M, event: D }) : e.linkTrack("agent-video", { ...M, event: D }, d, ["done"]);
|
|
543
546
|
}
|
|
544
|
-
B.includes(d) && ((
|
|
547
|
+
B.includes(d) && ((w = (l = r.callbacks).onError) == null || w.call(l, new Error(`Stream failed with event ${d}`), { data: m })), m.event === p.StreamDone && c();
|
|
545
548
|
}
|
|
546
549
|
}
|
|
547
550
|
};
|
|
@@ -650,7 +653,7 @@ function $t(e) {
|
|
|
650
653
|
freezeDuration: s.totalFreezesDuration
|
|
651
654
|
};
|
|
652
655
|
}
|
|
653
|
-
function
|
|
656
|
+
function Ae(e, t, r) {
|
|
654
657
|
const a = e.map((i, d) => d === 0 ? r ? {
|
|
655
658
|
timestamp: i.timestamp,
|
|
656
659
|
duration: 0,
|
|
@@ -740,13 +743,13 @@ function cr(e, t) {
|
|
|
740
743
|
c = setTimeout(i, ee);
|
|
741
744
|
return;
|
|
742
745
|
}
|
|
743
|
-
const l = m.totalAudioEnergy ?? 0,
|
|
746
|
+
const l = m.totalAudioEnergy ?? 0, w = m.totalSamplesReceived ?? 0;
|
|
744
747
|
if (!a) {
|
|
745
|
-
s = l, o =
|
|
748
|
+
s = l, o = w, a = !0, c = setTimeout(i, ee);
|
|
746
749
|
return;
|
|
747
750
|
}
|
|
748
|
-
const
|
|
749
|
-
if (s = l, o =
|
|
751
|
+
const p = l - s, y = w - o;
|
|
752
|
+
if (s = l, o = w, y > 0 && p > 0) {
|
|
750
753
|
r = !1, t(n);
|
|
751
754
|
return;
|
|
752
755
|
}
|
|
@@ -782,18 +785,18 @@ function Vt() {
|
|
|
782
785
|
};
|
|
783
786
|
}
|
|
784
787
|
function Kt(e, t, r, a, c) {
|
|
785
|
-
let s = null, o = [], n, i = 0, d = !1, m = te.Unknown, l = te.Unknown,
|
|
786
|
-
const
|
|
788
|
+
let s = null, o = [], n, i = 0, d = !1, m = te.Unknown, l = te.Unknown, w = 0, p = 0;
|
|
789
|
+
const y = Vt();
|
|
787
790
|
async function B() {
|
|
788
791
|
const M = await e();
|
|
789
792
|
if (!M)
|
|
790
793
|
return;
|
|
791
|
-
const { isReceiving: D, avgJitterDelayInInterval: $, freezeCount:
|
|
794
|
+
const { isReceiving: D, avgJitterDelayInInterval: $, freezeCount: T } = y(M), q = $t(M);
|
|
792
795
|
if (D)
|
|
793
|
-
i = 0,
|
|
796
|
+
i = 0, w = T - p, l = $ < Ft ? te.Strong : $ > Nt && w > 1 ? te.Weak : m, l !== m && (c == null || c(l), m = l, p += w, w = 0), d || (a == null || a(k.Start), n = o[o.length - 1], o = [], d = !0), o.push(q);
|
|
794
797
|
else if (d && (i++, i >= zt)) {
|
|
795
|
-
const J =
|
|
796
|
-
a == null || a(k.Stop, J), t() || r(),
|
|
798
|
+
const J = Ae(o, oe, n);
|
|
799
|
+
a == null || a(k.Stop, J), t() || r(), p = T, d = !1;
|
|
797
800
|
}
|
|
798
801
|
}
|
|
799
802
|
return {
|
|
@@ -803,11 +806,11 @@ function Kt(e, t, r, a, c) {
|
|
|
803
806
|
stop: () => {
|
|
804
807
|
s && (clearInterval(s), s = null);
|
|
805
808
|
},
|
|
806
|
-
getReport: () =>
|
|
809
|
+
getReport: () => Ae(o, oe, n)
|
|
807
810
|
};
|
|
808
811
|
}
|
|
809
812
|
const Ut = (window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection).bind(window);
|
|
810
|
-
function
|
|
813
|
+
function be(e) {
|
|
811
814
|
switch (e) {
|
|
812
815
|
case "connected":
|
|
813
816
|
return L.Connected;
|
|
@@ -876,21 +879,21 @@ function xe({
|
|
|
876
879
|
async function Ht(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = de, analytics: o }, n) {
|
|
877
880
|
var E;
|
|
878
881
|
const i = Pt(r, "WebRTCStreamingManager"), d = Wt(i);
|
|
879
|
-
let m = !1, l = !1,
|
|
880
|
-
const { startConnection:
|
|
882
|
+
let m = !1, l = !1, w = k.Stop, p = k.Stop;
|
|
883
|
+
const { startConnection: y, sendStreamRequest: B, close: M, createStream: D, addIceCandidate: $ } = Lt(
|
|
881
884
|
c,
|
|
882
885
|
s,
|
|
883
886
|
e,
|
|
884
887
|
a.onError
|
|
885
888
|
), {
|
|
886
|
-
id:
|
|
889
|
+
id: T,
|
|
887
890
|
offer: q,
|
|
888
891
|
ice_servers: J,
|
|
889
892
|
session_id: V,
|
|
890
893
|
fluent: X,
|
|
891
894
|
interrupt_enabled: O
|
|
892
895
|
} = await D(t, n);
|
|
893
|
-
(E = a.onStreamCreated) == null || E.call(a, { stream_id:
|
|
896
|
+
(E = a.onStreamCreated) == null || E.call(a, { stream_id: T, session_id: V, agent_id: e });
|
|
894
897
|
const I = new Ut({ iceServers: J }), Y = I.createDataChannel("JanusDataChannel");
|
|
895
898
|
if (!V)
|
|
896
899
|
throw new Error("Could not create session_id");
|
|
@@ -906,8 +909,8 @@ async function Ht(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = de,
|
|
|
906
909
|
ie,
|
|
907
910
|
u,
|
|
908
911
|
(f, h) => xe({
|
|
909
|
-
statsSignal:
|
|
910
|
-
dataChannelSignal: K === W.Legacy ?
|
|
912
|
+
statsSignal: p = f,
|
|
913
|
+
dataChannelSignal: K === W.Legacy ? w : void 0,
|
|
911
914
|
onVideoStateChange: a.onVideoStateChange,
|
|
912
915
|
onAgentActivityStateChange: a.onAgentActivityStateChange,
|
|
913
916
|
report: h,
|
|
@@ -924,7 +927,7 @@ async function Ht(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = de,
|
|
|
924
927
|
i("peerConnection.onicecandidate", f);
|
|
925
928
|
try {
|
|
926
929
|
f.candidate && f.candidate.sdpMid && f.candidate.sdpMLineIndex !== null ? $(
|
|
927
|
-
|
|
930
|
+
T,
|
|
928
931
|
{
|
|
929
932
|
candidate: f.candidate.candidate,
|
|
930
933
|
sdpMid: f.candidate.sdpMid,
|
|
@@ -932,26 +935,26 @@ async function Ht(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = de,
|
|
|
932
935
|
},
|
|
933
936
|
V,
|
|
934
937
|
n
|
|
935
|
-
) : $(
|
|
936
|
-
} catch (
|
|
937
|
-
(h = a.onError) == null || h.call(a,
|
|
938
|
+
) : $(T, { candidate: null }, V, n);
|
|
939
|
+
} catch (A) {
|
|
940
|
+
(h = a.onError) == null || h.call(a, A, { streamId: T });
|
|
938
941
|
}
|
|
939
942
|
}, Y.onopen = () => {
|
|
940
943
|
l = !0, (!ae || m) && u();
|
|
941
944
|
};
|
|
942
945
|
let v = null;
|
|
943
|
-
const
|
|
946
|
+
const C = (f) => {
|
|
944
947
|
var h;
|
|
945
948
|
v = f, (h = a.onVideoIdChange) == null || h.call(a, f);
|
|
946
949
|
};
|
|
947
950
|
function S(f, h) {
|
|
948
951
|
if (f === P.StreamStarted && typeof h == "object" && "metadata" in h) {
|
|
949
|
-
const
|
|
950
|
-
|
|
952
|
+
const A = h.metadata;
|
|
953
|
+
C(A.videoId);
|
|
951
954
|
}
|
|
952
|
-
f === P.StreamDone &&
|
|
953
|
-
statsSignal: K === W.Legacy ?
|
|
954
|
-
dataChannelSignal:
|
|
955
|
+
f === P.StreamDone && C(null), w = f === P.StreamStarted ? k.Start : k.Stop, xe({
|
|
956
|
+
statsSignal: K === W.Legacy ? p : void 0,
|
|
957
|
+
dataChannelSignal: w,
|
|
955
958
|
onVideoStateChange: a.onVideoStateChange,
|
|
956
959
|
onAgentActivityStateChange: a.onAgentActivityStateChange,
|
|
957
960
|
streamType: K,
|
|
@@ -959,9 +962,9 @@ async function Ht(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = de,
|
|
|
959
962
|
});
|
|
960
963
|
}
|
|
961
964
|
function R(f, h) {
|
|
962
|
-
var
|
|
963
|
-
const
|
|
964
|
-
|
|
965
|
+
var _;
|
|
966
|
+
const A = typeof h == "string" ? h : h == null ? void 0 : h.metadata;
|
|
967
|
+
A && o.enrich({ streamMetadata: A }), (_ = a.onStreamReady) == null || _.call(a);
|
|
965
968
|
}
|
|
966
969
|
const j = {
|
|
967
970
|
[P.StreamStarted]: S,
|
|
@@ -969,32 +972,32 @@ async function Ht(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = de,
|
|
|
969
972
|
[P.StreamReady]: R
|
|
970
973
|
};
|
|
971
974
|
Y.onmessage = (f) => {
|
|
972
|
-
var
|
|
973
|
-
const { subject: h, data:
|
|
974
|
-
(
|
|
975
|
+
var _;
|
|
976
|
+
const { subject: h, data: A } = d(f.data);
|
|
977
|
+
(_ = j[h]) == null || _.call(j, h, A);
|
|
975
978
|
}, I.oniceconnectionstatechange = () => {
|
|
976
979
|
var h;
|
|
977
980
|
i("peerConnection.oniceconnectionstatechange => " + I.iceConnectionState);
|
|
978
|
-
const f =
|
|
981
|
+
const f = be(I.iceConnectionState);
|
|
979
982
|
f !== L.Connected && ((h = a.onConnectionStateChange) == null || h.call(a, f));
|
|
980
983
|
}, I.ontrack = (f) => {
|
|
981
984
|
var h;
|
|
982
985
|
i("peerConnection.ontrack", f), i("CALLBACK: onSrcObjectReady"), (h = a.onSrcObjectReady) == null || h.call(a, f.streams[0]);
|
|
983
986
|
}, await I.setRemoteDescription(q), i("set remote description OK");
|
|
984
|
-
const
|
|
985
|
-
i("create answer OK"), await I.setLocalDescription(
|
|
986
|
-
function
|
|
987
|
-
var h,
|
|
987
|
+
const F = await I.createAnswer();
|
|
988
|
+
i("create answer OK"), await I.setLocalDescription(F), i("set local description OK"), await y(T, F, V, n), i("start connection OK");
|
|
989
|
+
function N(f) {
|
|
990
|
+
var h, A;
|
|
988
991
|
if (!m || Y.readyState !== "open") {
|
|
989
992
|
i("Data channel is not ready for sending messages"), (h = a.onError) == null || h.call(a, new Error("Data channel is not ready for sending messages"), {
|
|
990
|
-
streamId:
|
|
993
|
+
streamId: T
|
|
991
994
|
});
|
|
992
995
|
return;
|
|
993
996
|
}
|
|
994
997
|
try {
|
|
995
998
|
Y.send(f);
|
|
996
|
-
} catch (
|
|
997
|
-
i("Error sending data channel message",
|
|
999
|
+
} catch (_) {
|
|
1000
|
+
i("Error sending data channel message", _), (A = a.onError) == null || A.call(a, _, { streamId: T });
|
|
998
1001
|
}
|
|
999
1002
|
}
|
|
1000
1003
|
return {
|
|
@@ -1003,15 +1006,15 @@ async function Ht(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = de,
|
|
|
1003
1006
|
* @param payload
|
|
1004
1007
|
*/
|
|
1005
1008
|
speak(f) {
|
|
1006
|
-
return B(
|
|
1009
|
+
return B(T, V, f);
|
|
1007
1010
|
},
|
|
1008
1011
|
/**
|
|
1009
1012
|
* Method to close RTC connection
|
|
1010
1013
|
*/
|
|
1011
1014
|
async disconnect() {
|
|
1012
1015
|
var f;
|
|
1013
|
-
if (
|
|
1014
|
-
const h =
|
|
1016
|
+
if (T) {
|
|
1017
|
+
const h = be(I.iceConnectionState);
|
|
1015
1018
|
if (I) {
|
|
1016
1019
|
if (h === L.New) {
|
|
1017
1020
|
g.stop();
|
|
@@ -1020,15 +1023,15 @@ async function Ht(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = de,
|
|
|
1020
1023
|
I.close(), I.oniceconnectionstatechange = null, I.onnegotiationneeded = null, I.onicecandidate = null, I.ontrack = null;
|
|
1021
1024
|
}
|
|
1022
1025
|
try {
|
|
1023
|
-
h === L.Connected && await M(
|
|
1026
|
+
h === L.Connected && await M(T, V).catch((A) => {
|
|
1024
1027
|
});
|
|
1025
|
-
} catch (
|
|
1026
|
-
i("Error on close stream connection",
|
|
1028
|
+
} catch (A) {
|
|
1029
|
+
i("Error on close stream connection", A);
|
|
1027
1030
|
}
|
|
1028
1031
|
(f = a.onAgentActivityStateChange) == null || f.call(a, ne.Idle), g.stop();
|
|
1029
1032
|
}
|
|
1030
1033
|
},
|
|
1031
|
-
sendDataChannelMessage:
|
|
1034
|
+
sendDataChannelMessage: N,
|
|
1032
1035
|
/**
|
|
1033
1036
|
* Session identifier information, should be returned in the body of all streaming requests
|
|
1034
1037
|
*/
|
|
@@ -1036,7 +1039,7 @@ async function Ht(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = de,
|
|
|
1036
1039
|
/**
|
|
1037
1040
|
* Id of current RTC stream
|
|
1038
1041
|
*/
|
|
1039
|
-
streamId:
|
|
1042
|
+
streamId: T,
|
|
1040
1043
|
streamType: K,
|
|
1041
1044
|
interruptAvailable: O ?? !1,
|
|
1042
1045
|
isInterruptible: !0,
|
|
@@ -1052,7 +1055,7 @@ async function Ht(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = de,
|
|
|
1052
1055
|
videoId: v,
|
|
1053
1056
|
timestamp: Date.now()
|
|
1054
1057
|
};
|
|
1055
|
-
|
|
1058
|
+
N(JSON.stringify(h));
|
|
1056
1059
|
}
|
|
1057
1060
|
};
|
|
1058
1061
|
}
|
|
@@ -1068,7 +1071,7 @@ async function qt(e, t, r, a) {
|
|
|
1068
1071
|
const { version: s, ...o } = t;
|
|
1069
1072
|
switch (o.transport.provider) {
|
|
1070
1073
|
case pe.Livekit:
|
|
1071
|
-
const { createLiveKitStreamingManager: n } = await import("./livekit-manager-
|
|
1074
|
+
const { createLiveKitStreamingManager: n } = await import("./livekit-manager-_ObM1JYd.js");
|
|
1072
1075
|
return n(c, o, r);
|
|
1073
1076
|
default:
|
|
1074
1077
|
throw new Error(`Unsupported transport provider: ${o.transport.provider}`);
|
|
@@ -1169,7 +1172,7 @@ function nr(e, t, r) {
|
|
|
1169
1172
|
});
|
|
1170
1173
|
}
|
|
1171
1174
|
function Pe(e, t, r, a) {
|
|
1172
|
-
return H.reset(),
|
|
1175
|
+
return H.reset(), _e.update(), new Promise(async (c, s) => {
|
|
1173
1176
|
try {
|
|
1174
1177
|
let o, n = !1;
|
|
1175
1178
|
const i = Qt(e, t);
|
|
@@ -1186,29 +1189,29 @@ function Pe(e, t, r, a) {
|
|
|
1186
1189
|
analytics: r,
|
|
1187
1190
|
callbacks: {
|
|
1188
1191
|
...t.callbacks,
|
|
1189
|
-
onConnectionStateChange: (l,
|
|
1190
|
-
var
|
|
1191
|
-
(
|
|
1192
|
+
onConnectionStateChange: (l, w) => {
|
|
1193
|
+
var p, y;
|
|
1194
|
+
(y = (p = t.callbacks).onConnectionStateChange) == null || y.call(p, l), Zt(l, w, r), l === L.Connected && (o ? c(o) : n = !0);
|
|
1192
1195
|
},
|
|
1193
|
-
onVideoStateChange: (l,
|
|
1194
|
-
var
|
|
1195
|
-
(
|
|
1196
|
+
onVideoStateChange: (l, w) => {
|
|
1197
|
+
var p, y;
|
|
1198
|
+
(y = (p = t.callbacks).onVideoStateChange) == null || y.call(p, l), er(
|
|
1196
1199
|
l,
|
|
1197
1200
|
e,
|
|
1198
|
-
|
|
1201
|
+
w,
|
|
1199
1202
|
r,
|
|
1200
1203
|
o.streamType
|
|
1201
1204
|
);
|
|
1202
1205
|
},
|
|
1203
1206
|
onAgentActivityStateChange: (l) => {
|
|
1204
|
-
var
|
|
1205
|
-
(
|
|
1207
|
+
var w, p;
|
|
1208
|
+
(p = (w = t.callbacks).onAgentActivityStateChange) == null || p.call(w, l), l === ne.Talking ? (fe.update(), d = (y) => {
|
|
1206
1209
|
Le(
|
|
1207
1210
|
k.Start,
|
|
1208
1211
|
e,
|
|
1209
1212
|
r,
|
|
1210
1213
|
o.streamType,
|
|
1211
|
-
|
|
1214
|
+
y
|
|
1212
1215
|
), d = null;
|
|
1213
1216
|
}, m || d({ latency: H.get(!0) })) : (fe.reset(), d = null, Le(
|
|
1214
1217
|
k.Stop,
|
|
@@ -1221,13 +1224,13 @@ function Pe(e, t, r, a) {
|
|
|
1221
1224
|
d == null || d(l);
|
|
1222
1225
|
},
|
|
1223
1226
|
onStreamReady: () => {
|
|
1224
|
-
const l =
|
|
1227
|
+
const l = _e.get(!0);
|
|
1225
1228
|
r.track("agent-chat", { event: "ready", latency: l });
|
|
1226
1229
|
},
|
|
1227
|
-
onToolEvent: (l,
|
|
1228
|
-
var
|
|
1229
|
-
(
|
|
1230
|
-
}
|
|
1230
|
+
onToolEvent: ((l, w) => {
|
|
1231
|
+
var p, y;
|
|
1232
|
+
(y = (p = t.callbacks).onToolEvent) == null || y.call(p, l, w), nr(l, w, r);
|
|
1233
|
+
})
|
|
1231
1234
|
}
|
|
1232
1235
|
},
|
|
1233
1236
|
a
|
|
@@ -1238,10 +1241,10 @@ function Pe(e, t, r, a) {
|
|
|
1238
1241
|
});
|
|
1239
1242
|
}
|
|
1240
1243
|
async function ar(e, t, r, a, c) {
|
|
1241
|
-
var m, l,
|
|
1244
|
+
var m, l, w, p;
|
|
1242
1245
|
const s = async () => {
|
|
1243
1246
|
if (he(e.presenter.type)) {
|
|
1244
|
-
const
|
|
1247
|
+
const y = await Pe(e, t, a), B = `${Xt}_${y.sessionId}`, M = (/* @__PURE__ */ new Date()).toISOString();
|
|
1245
1248
|
return { chatResult: {
|
|
1246
1249
|
chatMode: x.Functional,
|
|
1247
1250
|
chat: {
|
|
@@ -1255,9 +1258,9 @@ async function ar(e, t, r, a, c) {
|
|
|
1255
1258
|
chat_mode: x.Functional,
|
|
1256
1259
|
messages: []
|
|
1257
1260
|
}
|
|
1258
|
-
}, streamingManager:
|
|
1261
|
+
}, streamingManager: y };
|
|
1259
1262
|
} else {
|
|
1260
|
-
const
|
|
1263
|
+
const y = new AbortController(), B = y.signal;
|
|
1261
1264
|
let M;
|
|
1262
1265
|
try {
|
|
1263
1266
|
const D = Ke(
|
|
@@ -1267,15 +1270,15 @@ async function ar(e, t, r, a, c) {
|
|
|
1267
1270
|
t.mode,
|
|
1268
1271
|
t.persistentChat,
|
|
1269
1272
|
c
|
|
1270
|
-
), $ = Pe(e, t, a, B).then((J) => (M = J, J)), [
|
|
1271
|
-
return { chatResult:
|
|
1273
|
+
), $ = Pe(e, t, a, B).then((J) => (M = J, J)), [T, q] = await Promise.all([D, $]);
|
|
1274
|
+
return { chatResult: T, streamingManager: q };
|
|
1272
1275
|
} catch (D) {
|
|
1273
|
-
throw
|
|
1276
|
+
throw y.abort(), M && await M.disconnect().catch(() => {
|
|
1274
1277
|
}), D;
|
|
1275
1278
|
}
|
|
1276
1279
|
}
|
|
1277
1280
|
}, { chatResult: o, streamingManager: n } = await s(), { chat: i, chatMode: d } = o;
|
|
1278
|
-
return d && t.mode !== void 0 && d !== t.mode && (t.mode = d, (l = (m = t.callbacks).onModeChange) == null || l.call(m, d), d !== x.Functional) ? ((
|
|
1281
|
+
return d && t.mode !== void 0 && d !== t.mode && (t.mode = d, (l = (m = t.callbacks).onModeChange) == null || l.call(m, d), d !== x.Functional) ? ((p = (w = t.callbacks).onError) == null || p.call(w, new qe(d)), n == null || n.disconnect(), { chat: i }) : { chat: i, streamingManager: n };
|
|
1279
1282
|
}
|
|
1280
1283
|
async function dr(e, t) {
|
|
1281
1284
|
var Y, K, ae, ie;
|
|
@@ -1295,17 +1298,17 @@ async function dr(e, t) {
|
|
|
1295
1298
|
});
|
|
1296
1299
|
const m = vt(t.auth, s, t.callbacks.onError, t.externalId), l = await m.getById(e);
|
|
1297
1300
|
t.debug = t.debug || ((Y = l == null ? void 0 : l.advanced_settings) == null ? void 0 : Y.ui_debug_mode);
|
|
1298
|
-
const
|
|
1301
|
+
const w = he(l.presenter.type);
|
|
1299
1302
|
i.enrich(Ct(l));
|
|
1300
|
-
const { onMessage:
|
|
1303
|
+
const { onMessage: p, clearQueue: y } = xt(i, n, t, l, () => {
|
|
1301
1304
|
var u, g, v;
|
|
1302
1305
|
(u = n.socketManager) == null || u.disconnect(), (v = (g = t.callbacks).onConnectionStateChange) == null || v.call(g, L.Disconnected);
|
|
1303
1306
|
});
|
|
1304
1307
|
n.messages = Mt(t.initialMessages), (ae = (K = t.callbacks).onNewMessage) == null || ae.call(K, [...n.messages], "answer");
|
|
1305
1308
|
const B = (u) => {
|
|
1306
1309
|
}, M = ({ type: u }) => {
|
|
1307
|
-
var v,
|
|
1308
|
-
if (!((v = n.streamingManager) != null && v.interruptAvailable) || !((
|
|
1310
|
+
var v, C, S, R;
|
|
1311
|
+
if (!((v = n.streamingManager) != null && v.interruptAvailable) || !((C = n.streamingManager) != null && C.isInterruptible)) return;
|
|
1309
1312
|
const g = n.messages[n.messages.length - 1];
|
|
1310
1313
|
i.track("agent-video-interrupt", {
|
|
1311
1314
|
type: u || "click",
|
|
@@ -1319,22 +1322,22 @@ async function dr(e, t) {
|
|
|
1319
1322
|
if (!v)
|
|
1320
1323
|
throw new Error(`No handler registered for client tool: ${u}`);
|
|
1321
1324
|
try {
|
|
1322
|
-
const
|
|
1323
|
-
return await v(
|
|
1324
|
-
} catch (
|
|
1325
|
-
throw new Error(`Client tool "${u}" failed: ${
|
|
1325
|
+
const C = JSON.parse(g.payload);
|
|
1326
|
+
return await v(C);
|
|
1327
|
+
} catch (C) {
|
|
1328
|
+
throw new Error(`Client tool "${u}" failed: ${C.message}`);
|
|
1326
1329
|
}
|
|
1327
1330
|
};
|
|
1328
1331
|
}
|
|
1329
|
-
function
|
|
1330
|
-
var u, g, v,
|
|
1332
|
+
function T() {
|
|
1333
|
+
var u, g, v, C;
|
|
1331
1334
|
for (const [S] of D)
|
|
1332
|
-
(g = (u = n.streamingManager) == null ? void 0 : u.unregisterRpcMethod) == null || g.call(u, S), (
|
|
1335
|
+
(g = (u = n.streamingManager) == null ? void 0 : u.unregisterRpcMethod) == null || g.call(u, S), (C = (v = n.streamingManager) == null ? void 0 : v.registerRpcMethod) == null || C.call(v, S, $(S));
|
|
1333
1336
|
}
|
|
1334
1337
|
function q(u, g) {
|
|
1335
|
-
var
|
|
1338
|
+
var C, S;
|
|
1336
1339
|
const v = !D.has(u);
|
|
1337
|
-
D.set(u, g), v && ((S = (
|
|
1340
|
+
D.set(u, g), v && ((S = (C = n.streamingManager) == null ? void 0 : C.registerRpcMethod) == null || S.call(C, u, $(u)));
|
|
1338
1341
|
}
|
|
1339
1342
|
function J(u) {
|
|
1340
1343
|
var g, v;
|
|
@@ -1345,12 +1348,12 @@ async function dr(e, t) {
|
|
|
1345
1348
|
i.track("agent-sdk", { event: "loaded", ...yt(l) }, V);
|
|
1346
1349
|
});
|
|
1347
1350
|
async function X(u) {
|
|
1348
|
-
var j,
|
|
1349
|
-
(
|
|
1350
|
-
const g = o === x.DirectPlayback ||
|
|
1351
|
+
var j, F, N, E, f, h, A;
|
|
1352
|
+
(F = (j = t.callbacks).onConnectionStateChange) == null || F.call(j, L.Connecting), H.reset(), u && !r && (delete n.chat, (E = (N = t.callbacks).onNewMessage) == null || E.call(N, [...n.messages], "answer"));
|
|
1353
|
+
const g = o === x.DirectPlayback || w ? Promise.resolve(void 0) : Tt(
|
|
1351
1354
|
t.auth,
|
|
1352
1355
|
c,
|
|
1353
|
-
{ onMessage:
|
|
1356
|
+
{ onMessage: p, onError: t.callbacks.onError },
|
|
1354
1357
|
t.externalId
|
|
1355
1358
|
), v = ue(
|
|
1356
1359
|
() => ar(
|
|
@@ -1361,7 +1364,7 @@ async function dr(e, t) {
|
|
|
1361
1364
|
callbacks: {
|
|
1362
1365
|
...t.callbacks,
|
|
1363
1366
|
onVideoIdChange: B,
|
|
1364
|
-
onMessage:
|
|
1367
|
+
onMessage: p
|
|
1365
1368
|
}
|
|
1366
1369
|
},
|
|
1367
1370
|
m,
|
|
@@ -1372,22 +1375,22 @@ async function dr(e, t) {
|
|
|
1372
1375
|
limit: 3,
|
|
1373
1376
|
timeout: it,
|
|
1374
1377
|
timeoutErrorMessage: "Timeout initializing the stream",
|
|
1375
|
-
shouldRetryFn: (
|
|
1378
|
+
shouldRetryFn: (_) => (_ == null ? void 0 : _.message) !== "Could not connect" && _.status !== 429 && (_ == null ? void 0 : _.message) !== "InsufficientCreditsError",
|
|
1376
1379
|
delayMs: 1e3
|
|
1377
1380
|
}
|
|
1378
|
-
).catch((
|
|
1379
|
-
var
|
|
1380
|
-
throw I(x.Maintenance), (U = (
|
|
1381
|
-
}), [
|
|
1382
|
-
R && R.id !== ((f = n.chat) == null ? void 0 : f.id) && ((
|
|
1381
|
+
).catch((_) => {
|
|
1382
|
+
var b, U;
|
|
1383
|
+
throw I(x.Maintenance), (U = (b = t.callbacks).onConnectionStateChange) == null || U.call(b, L.Fail), _;
|
|
1384
|
+
}), [C, { streamingManager: S, chat: R }] = await Promise.all([g, v]);
|
|
1385
|
+
R && R.id !== ((f = n.chat) == null ? void 0 : f.id) && ((A = (h = t.callbacks).onNewChat) == null || A.call(h, R.id)), n.streamingManager = S, n.socketManager = C, n.chat = R, T(), r = !1, i.enrich({
|
|
1383
1386
|
chatId: R == null ? void 0 : R.id,
|
|
1384
1387
|
streamId: S == null ? void 0 : S.streamId,
|
|
1385
1388
|
mode: n.chatMode
|
|
1386
1389
|
}), I((R == null ? void 0 : R.chat_mode) ?? o);
|
|
1387
1390
|
}
|
|
1388
1391
|
async function O() {
|
|
1389
|
-
var u, g, v,
|
|
1390
|
-
(u = n.socketManager) == null || u.disconnect(), await ((g = n.streamingManager) == null ? void 0 : g.disconnect()), delete n.streamingManager, delete n.socketManager, (
|
|
1392
|
+
var u, g, v, C;
|
|
1393
|
+
(u = n.socketManager) == null || u.disconnect(), await ((g = n.streamingManager) == null ? void 0 : g.disconnect()), delete n.streamingManager, delete n.socketManager, (C = (v = t.callbacks).onConnectionStateChange) == null || C.call(v, L.Disconnected);
|
|
1391
1394
|
}
|
|
1392
1395
|
async function I(u) {
|
|
1393
1396
|
var g, v;
|
|
@@ -1415,7 +1418,7 @@ async function dr(e, t) {
|
|
|
1415
1418
|
},
|
|
1416
1419
|
async reconnect() {
|
|
1417
1420
|
const u = n.streamingManager;
|
|
1418
|
-
if (
|
|
1421
|
+
if (w && (u != null && u.reconnect)) {
|
|
1419
1422
|
try {
|
|
1420
1423
|
await u.reconnect(), i.track("agent-chat", {
|
|
1421
1424
|
event: "reconnect",
|
|
@@ -1458,7 +1461,7 @@ async function dr(e, t) {
|
|
|
1458
1461
|
return (u = n.streamingManager) != null && u.unpublishCameraStream ? n.streamingManager.unpublishCameraStream() : Promise.resolve();
|
|
1459
1462
|
},
|
|
1460
1463
|
async chat(u) {
|
|
1461
|
-
var S, R, j,
|
|
1464
|
+
var S, R, j, F, N;
|
|
1462
1465
|
const g = () => {
|
|
1463
1466
|
if (ze(o))
|
|
1464
1467
|
throw new G(`${o} is enabled, chat is disabled`);
|
|
@@ -1489,19 +1492,19 @@ async function dr(e, t) {
|
|
|
1489
1492
|
n.chat = h.chat, (f = (E = t.callbacks).onNewChat) == null || f.call(E, n.chat.id);
|
|
1490
1493
|
}
|
|
1491
1494
|
return n.chat.id;
|
|
1492
|
-
},
|
|
1495
|
+
}, C = async (E, f) => {
|
|
1493
1496
|
const h = n.chatMode === x.Playground;
|
|
1494
|
-
return ue(
|
|
1495
|
-
var
|
|
1496
|
-
return await ((U = (
|
|
1497
|
+
return ue(w && !h ? async () => {
|
|
1498
|
+
var b, U;
|
|
1499
|
+
return await ((U = (b = n.streamingManager) == null ? void 0 : b.sendTextMessage) == null ? void 0 : U.call(b, u)), Promise.resolve({});
|
|
1497
1500
|
} : async () => {
|
|
1498
|
-
var
|
|
1501
|
+
var b, U;
|
|
1499
1502
|
return m.chat(
|
|
1500
1503
|
l.id,
|
|
1501
1504
|
f,
|
|
1502
1505
|
{
|
|
1503
1506
|
chatMode: n.chatMode,
|
|
1504
|
-
streamId: (
|
|
1507
|
+
streamId: (b = n.streamingManager) == null ? void 0 : b.streamId,
|
|
1505
1508
|
sessionId: (U = n.streamingManager) == null ? void 0 : U.sessionId,
|
|
1506
1509
|
messages: E.map(({ matches: We, ...se }) => se)
|
|
1507
1510
|
},
|
|
@@ -1512,10 +1515,10 @@ async function dr(e, t) {
|
|
|
1512
1515
|
);
|
|
1513
1516
|
}, {
|
|
1514
1517
|
limit: 2,
|
|
1515
|
-
shouldRetryFn: (
|
|
1518
|
+
shouldRetryFn: (b) => {
|
|
1516
1519
|
var se, ve, ye, Ce;
|
|
1517
|
-
const U = (se =
|
|
1518
|
-
return !((ve =
|
|
1520
|
+
const U = (se = b == null ? void 0 : b.message) == null ? void 0 : se.includes("missing or invalid session_id");
|
|
1521
|
+
return !((ve = b == null ? void 0 : b.message) == null ? void 0 : ve.includes("Stream Error")) && !U ? ((Ce = (ye = t.callbacks).onError) == null || Ce.call(ye, b), !1) : !0;
|
|
1519
1522
|
},
|
|
1520
1523
|
onRetry: async () => {
|
|
1521
1524
|
await O(), await X(!1);
|
|
@@ -1523,14 +1526,14 @@ async function dr(e, t) {
|
|
|
1523
1526
|
});
|
|
1524
1527
|
};
|
|
1525
1528
|
try {
|
|
1526
|
-
|
|
1529
|
+
y(), g(), n.messages.push({
|
|
1527
1530
|
id: Q(),
|
|
1528
1531
|
role: "user",
|
|
1529
1532
|
content: u,
|
|
1530
1533
|
parts: re(u),
|
|
1531
1534
|
created_at: new Date(H.update()).toISOString()
|
|
1532
1535
|
}), (R = (S = t.callbacks).onNewMessage) == null || R.call(S, [...n.messages], "user");
|
|
1533
|
-
const E = await v(), f = await
|
|
1536
|
+
const E = await v(), f = await C([...n.messages], E);
|
|
1534
1537
|
return f.result && n.messages.push({
|
|
1535
1538
|
id: Q(),
|
|
1536
1539
|
role: "assistant",
|
|
@@ -1542,25 +1545,25 @@ async function dr(e, t) {
|
|
|
1542
1545
|
}), i.track("agent-message-send", {
|
|
1543
1546
|
event: "success",
|
|
1544
1547
|
messages: n.messages.length + 1
|
|
1545
|
-
}), f.result && ((
|
|
1548
|
+
}), f.result && ((F = (j = t.callbacks).onNewMessage) == null || F.call(j, [...n.messages], "answer"), i.track("agent-message-received", {
|
|
1546
1549
|
latency: H.get(!0),
|
|
1547
1550
|
messages: n.messages.length
|
|
1548
1551
|
})), f;
|
|
1549
1552
|
} catch (E) {
|
|
1550
|
-
throw ((
|
|
1553
|
+
throw ((N = n.messages[n.messages.length - 1]) == null ? void 0 : N.role) === "assistant" && n.messages.pop(), i.track("agent-message-send", {
|
|
1551
1554
|
event: "error",
|
|
1552
1555
|
messages: n.messages.length
|
|
1553
1556
|
}), E;
|
|
1554
1557
|
}
|
|
1555
1558
|
},
|
|
1556
1559
|
rate(u, g, v) {
|
|
1557
|
-
var R, j,
|
|
1558
|
-
const
|
|
1560
|
+
var R, j, F, N;
|
|
1561
|
+
const C = n.messages.find((E) => E.id === u);
|
|
1559
1562
|
if (n.chat) {
|
|
1560
|
-
if (!
|
|
1563
|
+
if (!C)
|
|
1561
1564
|
throw new Error("Message not found");
|
|
1562
1565
|
} else throw new Error("Chat is not initialized");
|
|
1563
|
-
const S = ((R =
|
|
1566
|
+
const S = ((R = C.matches) == null ? void 0 : R.map((E) => [E.document_id, E.id])) ?? [];
|
|
1564
1567
|
return i.track("agent-rate", {
|
|
1565
1568
|
event: v ? "update" : "create",
|
|
1566
1569
|
thumb: g === 1 ? "up" : "down",
|
|
@@ -1568,12 +1571,12 @@ async function dr(e, t) {
|
|
|
1568
1571
|
matches: S,
|
|
1569
1572
|
score: g
|
|
1570
1573
|
}), v ? m.updateRating(l.id, n.chat.id, v, {
|
|
1571
|
-
knowledge_id: ((
|
|
1574
|
+
knowledge_id: ((F = l.knowledge) == null ? void 0 : F.id) ?? "",
|
|
1572
1575
|
message_id: u,
|
|
1573
1576
|
matches: S,
|
|
1574
1577
|
score: g
|
|
1575
1578
|
}) : m.createRating(l.id, n.chat.id, {
|
|
1576
|
-
knowledge_id: ((
|
|
1579
|
+
knowledge_id: ((N = l.knowledge) == null ? void 0 : N.id) ?? "",
|
|
1577
1580
|
message_id: u,
|
|
1578
1581
|
matches: S,
|
|
1579
1582
|
score: g
|
|
@@ -1636,7 +1639,7 @@ async function dr(e, t) {
|
|
|
1636
1639
|
}
|
|
1637
1640
|
export {
|
|
1638
1641
|
ne as A,
|
|
1639
|
-
|
|
1642
|
+
z as C,
|
|
1640
1643
|
rt as D,
|
|
1641
1644
|
tt as K,
|
|
1642
1645
|
Ge as P,
|
|
@@ -1655,17 +1658,17 @@ export {
|
|
|
1655
1658
|
Kt as g,
|
|
1656
1659
|
cr as h,
|
|
1657
1660
|
k as i,
|
|
1658
|
-
|
|
1659
|
-
|
|
1661
|
+
Qe as j,
|
|
1662
|
+
He as k,
|
|
1660
1663
|
H as l,
|
|
1661
|
-
|
|
1664
|
+
x as m,
|
|
1662
1665
|
or as n,
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1666
|
+
qe as o,
|
|
1667
|
+
nt as p,
|
|
1668
|
+
et as q,
|
|
1669
|
+
je as r,
|
|
1670
|
+
at as s,
|
|
1671
|
+
dr as t,
|
|
1672
|
+
sr as u,
|
|
1673
|
+
gt as v
|
|
1671
1674
|
};
|