@d-id/client-sdk 1.1.67-staging.311 → 1.1.67-staging.314
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.
|
@@ -35,7 +35,7 @@ class qe extends ce {
|
|
|
35
35
|
super({ kind: "WSError", description: t });
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
var Xe = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(Xe || {}), Ye = /* @__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))(Ye || {}), Ge = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(Ge || {}), Qe = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(Qe || {}), 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 Xe = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(Xe || {}), Ye = /* @__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))(Ye || {}), Ge = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(Ge || {}), Qe = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(Qe || {}), x = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e.Off = "Off", e))(x || {}), N = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Transcribe = "transcribe", e.Complete = "done", e))(N || {}), Ze = /* @__PURE__ */ ((e) => (e.KnowledgeProcessing = "knowledge/processing", e.KnowledgeIndexing = "knowledge/indexing", e.KnowledgeFailed = "knowledge/error", e.KnowledgeDone = "knowledge/done", e))(Ze || {}), et = /* @__PURE__ */ ((e) => (e.Knowledge = "knowledge", e.Document = "document", e.Record = "record", e))(et || {}), tt = /* @__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))(tt || {}), Pe = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e.Expressive = "expressive", e))(Pe || {});
|
|
39
39
|
const sr = (e) => {
|
|
40
40
|
switch (e) {
|
|
41
41
|
case "clip":
|
|
@@ -405,10 +405,10 @@ function It(e) {
|
|
|
405
405
|
function Mt(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(ze(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 = (h) => {
|
|
409
|
+
console.error(h), m == null || m("Websocket failed to connect", h), r(h);
|
|
410
|
+
}, l.onopen = (h) => {
|
|
411
|
+
i == null || i(h), t(l);
|
|
412
412
|
};
|
|
413
413
|
});
|
|
414
414
|
}
|
|
@@ -470,47 +470,57 @@ function bt(e, t, r) {
|
|
|
470
470
|
};
|
|
471
471
|
t.messages.push(c), r == null || r([...t.messages], "user");
|
|
472
472
|
}
|
|
473
|
-
function At(e, t, r, a, c, s) {
|
|
474
|
-
if (e ===
|
|
473
|
+
function At(e, t, r, a, c, s, o) {
|
|
474
|
+
if (e === N.Transcribe && t.content) {
|
|
475
475
|
bt(t, a, c);
|
|
476
476
|
return;
|
|
477
477
|
}
|
|
478
|
-
if (!(e ===
|
|
478
|
+
if (!(e === N.Partial || e === N.Answer))
|
|
479
479
|
return;
|
|
480
|
-
const
|
|
481
|
-
let
|
|
482
|
-
if ((
|
|
483
|
-
|
|
484
|
-
else if (!
|
|
485
|
-
|
|
480
|
+
const n = a.messages[a.messages.length - 1], i = o === "answer";
|
|
481
|
+
let d;
|
|
482
|
+
if ((n == null ? void 0 : n.role) === "assistant" && !i)
|
|
483
|
+
d = n;
|
|
484
|
+
else if (!n || n.role === "user" || i)
|
|
485
|
+
i && s(), d = {
|
|
486
486
|
id: t.id || `assistant-${Date.now()}`,
|
|
487
487
|
role: t.role || "assistant",
|
|
488
488
|
content: t.content || "",
|
|
489
489
|
parts: [],
|
|
490
490
|
created_at: t.created_at || (/* @__PURE__ */ new Date()).toISOString()
|
|
491
|
-
}, a.messages.push(
|
|
491
|
+
}, a.messages.push(d);
|
|
492
492
|
else
|
|
493
493
|
return;
|
|
494
|
-
const { content:
|
|
495
|
-
e ===
|
|
496
|
-
const
|
|
497
|
-
(
|
|
494
|
+
const { content: m, sequence: l } = t;
|
|
495
|
+
e === N.Partial ? r[l] = m : r.answer = m;
|
|
496
|
+
const h = _t(r);
|
|
497
|
+
(d.content !== h || e === N.Answer) && (d.content = h, d.parts = re(h), c == null || c([...a.messages], e));
|
|
498
498
|
}
|
|
499
499
|
function xt(e, t, r, a, c) {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
500
|
+
const s = {}, o = () => {
|
|
501
|
+
for (const d of Object.keys(s))
|
|
502
|
+
delete s[d];
|
|
503
|
+
};
|
|
504
|
+
let n = null;
|
|
503
505
|
const i = (d, m) => {
|
|
504
|
-
var l,
|
|
505
|
-
m === "user" && o(),
|
|
506
|
+
var l, h;
|
|
507
|
+
m === "user" && o(), (h = (l = r.callbacks).onNewMessage) == null || h.call(l, d, m);
|
|
506
508
|
};
|
|
507
509
|
return {
|
|
508
510
|
clearQueue: o,
|
|
509
511
|
onMessage: (d, m) => {
|
|
510
|
-
var l,
|
|
512
|
+
var l, h;
|
|
511
513
|
if ("content" in m) {
|
|
512
|
-
const v = d === P.ChatAnswer ?
|
|
513
|
-
At(
|
|
514
|
+
const v = d === P.ChatAnswer ? N.Answer : d === P.ChatAudioTranscribed ? N.Transcribe : d;
|
|
515
|
+
At(
|
|
516
|
+
v,
|
|
517
|
+
m,
|
|
518
|
+
s,
|
|
519
|
+
t,
|
|
520
|
+
i,
|
|
521
|
+
o,
|
|
522
|
+
n
|
|
523
|
+
), v === N.Partial ? n = "partial" : v === N.Answer && (n = "answer", o()), v === N.Answer && e.track("agent-message-received", {
|
|
514
524
|
content: m.content,
|
|
515
525
|
messages: t.messages.length,
|
|
516
526
|
mode: t.chatMode
|
|
@@ -521,14 +531,14 @@ function xt(e, t, r, a, c) {
|
|
|
521
531
|
const D = t.messages[t.messages.length - 1];
|
|
522
532
|
if ((D == null ? void 0 : D.role) === "assistant") {
|
|
523
533
|
const $ = { ...D, sentiment: m.sentiment };
|
|
524
|
-
t.messages[t.messages.length - 1] = $, i == null || i([...t.messages], n);
|
|
534
|
+
t.messages[t.messages.length - 1] = $, i == null || i([...t.messages], n ?? "answer");
|
|
525
535
|
}
|
|
526
536
|
}
|
|
527
537
|
if (k.includes(d)) {
|
|
528
538
|
const D = d.split("/")[1];
|
|
529
539
|
B.includes(d) ? e.track("agent-video", { ...M, event: D }) : e.linkTrack("agent-video", { ...M, event: D }, d, ["done"]);
|
|
530
540
|
}
|
|
531
|
-
B.includes(d) && ((
|
|
541
|
+
B.includes(d) && ((h = (l = r.callbacks).onError) == null || h.call(l, new Error(`Stream failed with event ${d}`), { data: m })), m.event === v.StreamDone && c();
|
|
532
542
|
}
|
|
533
543
|
}
|
|
534
544
|
};
|
|
@@ -727,13 +737,13 @@ function cr(e, t) {
|
|
|
727
737
|
c = setTimeout(i, ee);
|
|
728
738
|
return;
|
|
729
739
|
}
|
|
730
|
-
const l = m.totalAudioEnergy ?? 0,
|
|
740
|
+
const l = m.totalAudioEnergy ?? 0, h = m.totalSamplesReceived ?? 0;
|
|
731
741
|
if (!a) {
|
|
732
|
-
s = l, o =
|
|
742
|
+
s = l, o = h, a = !0, c = setTimeout(i, ee);
|
|
733
743
|
return;
|
|
734
744
|
}
|
|
735
|
-
const v = l - s, k =
|
|
736
|
-
if (s = l, o =
|
|
745
|
+
const v = l - s, k = h - o;
|
|
746
|
+
if (s = l, o = h, k > 0 && v > 0) {
|
|
737
747
|
r = !1, t(n);
|
|
738
748
|
return;
|
|
739
749
|
}
|
|
@@ -769,7 +779,7 @@ function Vt() {
|
|
|
769
779
|
};
|
|
770
780
|
}
|
|
771
781
|
function Kt(e, t, r, a, c) {
|
|
772
|
-
let s = null, o = [], n, i = 0, d = !1, m = te.Unknown, l = te.Unknown,
|
|
782
|
+
let s = null, o = [], n, i = 0, d = !1, m = te.Unknown, l = te.Unknown, h = 0, v = 0;
|
|
773
783
|
const k = Vt();
|
|
774
784
|
async function B() {
|
|
775
785
|
const M = await e();
|
|
@@ -777,7 +787,7 @@ function Kt(e, t, r, a, c) {
|
|
|
777
787
|
return;
|
|
778
788
|
const { isReceiving: D, avgJitterDelayInInterval: $, freezeCount: _ } = k(M), q = $t(M);
|
|
779
789
|
if (D)
|
|
780
|
-
i = 0,
|
|
790
|
+
i = 0, h = _ - v, l = $ < Ft ? te.Strong : $ > Nt && h > 1 ? te.Weak : m, l !== m && (c == null || c(l), m = l, v += h, h = 0), d || (a == null || a(S.Start), n = o[o.length - 1], o = [], d = !0), o.push(q);
|
|
781
791
|
else if (d && (i++, i >= zt)) {
|
|
782
792
|
const J = _e(o, oe, n);
|
|
783
793
|
a == null || a(S.Stop, J), t() || r(), v = _, d = !1;
|
|
@@ -863,7 +873,7 @@ function Ae({
|
|
|
863
873
|
async function Ht(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = de, analytics: o }, n) {
|
|
864
874
|
var E;
|
|
865
875
|
const i = Pt(r, "WebRTCStreamingManager"), d = Wt(i);
|
|
866
|
-
let m = !1, l = !1,
|
|
876
|
+
let m = !1, l = !1, h = S.Stop, v = S.Stop;
|
|
867
877
|
const { startConnection: k, sendStreamRequest: B, close: M, createStream: D, addIceCandidate: $ } = Lt(
|
|
868
878
|
c,
|
|
869
879
|
s,
|
|
@@ -873,17 +883,17 @@ async function Ht(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = de,
|
|
|
873
883
|
id: _,
|
|
874
884
|
offer: q,
|
|
875
885
|
ice_servers: J,
|
|
876
|
-
session_id:
|
|
886
|
+
session_id: V,
|
|
877
887
|
fluent: X,
|
|
878
888
|
interrupt_enabled: O
|
|
879
889
|
} = await D(t, n);
|
|
880
|
-
(E = a.onStreamCreated) == null || E.call(a, { stream_id: _, session_id:
|
|
890
|
+
(E = a.onStreamCreated) == null || E.call(a, { stream_id: _, session_id: V, agent_id: e });
|
|
881
891
|
const I = new Ut({ iceServers: J }), Y = I.createDataChannel("JanusDataChannel");
|
|
882
|
-
if (!
|
|
892
|
+
if (!V)
|
|
883
893
|
throw new Error("Could not create session_id");
|
|
884
|
-
const
|
|
894
|
+
const K = X ? W.Fluent : W.Legacy;
|
|
885
895
|
o.enrich({
|
|
886
|
-
"stream-type":
|
|
896
|
+
"stream-type": K
|
|
887
897
|
});
|
|
888
898
|
const ae = t.stream_warmup && !X, ie = () => m, u = () => {
|
|
889
899
|
var f;
|
|
@@ -892,22 +902,22 @@ async function Ht(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = de,
|
|
|
892
902
|
() => I.getStats(),
|
|
893
903
|
ie,
|
|
894
904
|
u,
|
|
895
|
-
(f,
|
|
905
|
+
(f, p) => Ae({
|
|
896
906
|
statsSignal: v = f,
|
|
897
|
-
dataChannelSignal:
|
|
907
|
+
dataChannelSignal: K === W.Legacy ? h : void 0,
|
|
898
908
|
onVideoStateChange: a.onVideoStateChange,
|
|
899
909
|
onAgentActivityStateChange: a.onAgentActivityStateChange,
|
|
900
|
-
report:
|
|
901
|
-
streamType:
|
|
910
|
+
report: p,
|
|
911
|
+
streamType: K,
|
|
902
912
|
log: i
|
|
903
913
|
}),
|
|
904
914
|
(f) => {
|
|
905
|
-
var
|
|
906
|
-
return (
|
|
915
|
+
var p;
|
|
916
|
+
return (p = a.onConnectivityStateChange) == null ? void 0 : p.call(a, f);
|
|
907
917
|
}
|
|
908
918
|
);
|
|
909
919
|
g.start(), I.onicecandidate = (f) => {
|
|
910
|
-
var
|
|
920
|
+
var p;
|
|
911
921
|
i("peerConnection.onicecandidate", f);
|
|
912
922
|
try {
|
|
913
923
|
f.candidate && f.candidate.sdpMid && f.candidate.sdpMLineIndex !== null ? $(
|
|
@@ -917,37 +927,37 @@ async function Ht(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = de,
|
|
|
917
927
|
sdpMid: f.candidate.sdpMid,
|
|
918
928
|
sdpMLineIndex: f.candidate.sdpMLineIndex
|
|
919
929
|
},
|
|
920
|
-
|
|
930
|
+
V,
|
|
921
931
|
n
|
|
922
|
-
) : $(_, { candidate: null },
|
|
932
|
+
) : $(_, { candidate: null }, V, n);
|
|
923
933
|
} catch (b) {
|
|
924
|
-
(
|
|
934
|
+
(p = a.onError) == null || p.call(a, b, { streamId: _ });
|
|
925
935
|
}
|
|
926
936
|
}, Y.onopen = () => {
|
|
927
937
|
l = !0, (!ae || m) && u();
|
|
928
938
|
};
|
|
929
|
-
let
|
|
939
|
+
let w = null;
|
|
930
940
|
const y = (f) => {
|
|
931
|
-
var
|
|
932
|
-
|
|
941
|
+
var p;
|
|
942
|
+
w = f, (p = a.onVideoIdChange) == null || p.call(a, f);
|
|
933
943
|
};
|
|
934
|
-
function C(f,
|
|
935
|
-
if (f === P.StreamStarted && typeof
|
|
936
|
-
const b =
|
|
944
|
+
function C(f, p) {
|
|
945
|
+
if (f === P.StreamStarted && typeof p == "object" && "metadata" in p) {
|
|
946
|
+
const b = p.metadata;
|
|
937
947
|
y(b.videoId);
|
|
938
948
|
}
|
|
939
|
-
f === P.StreamDone && y(null),
|
|
940
|
-
statsSignal:
|
|
941
|
-
dataChannelSignal:
|
|
949
|
+
f === P.StreamDone && y(null), h = f === P.StreamStarted ? S.Start : S.Stop, Ae({
|
|
950
|
+
statsSignal: K === W.Legacy ? v : void 0,
|
|
951
|
+
dataChannelSignal: h,
|
|
942
952
|
onVideoStateChange: a.onVideoStateChange,
|
|
943
953
|
onAgentActivityStateChange: a.onAgentActivityStateChange,
|
|
944
|
-
streamType:
|
|
954
|
+
streamType: K,
|
|
945
955
|
log: i
|
|
946
956
|
});
|
|
947
957
|
}
|
|
948
|
-
function R(f,
|
|
958
|
+
function R(f, p) {
|
|
949
959
|
var T;
|
|
950
|
-
const b = typeof
|
|
960
|
+
const b = typeof p == "string" ? p : p == null ? void 0 : p.metadata;
|
|
951
961
|
b && o.enrich({ streamMetadata: b }), (T = a.onStreamReady) == null || T.call(a);
|
|
952
962
|
}
|
|
953
963
|
const j = {
|
|
@@ -957,23 +967,23 @@ async function Ht(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = de,
|
|
|
957
967
|
};
|
|
958
968
|
Y.onmessage = (f) => {
|
|
959
969
|
var T;
|
|
960
|
-
const { subject:
|
|
961
|
-
(T = j[
|
|
970
|
+
const { subject: p, data: b } = d(f.data);
|
|
971
|
+
(T = j[p]) == null || T.call(j, p, b);
|
|
962
972
|
}, I.oniceconnectionstatechange = () => {
|
|
963
|
-
var
|
|
973
|
+
var p;
|
|
964
974
|
i("peerConnection.oniceconnectionstatechange => " + I.iceConnectionState);
|
|
965
975
|
const f = be(I.iceConnectionState);
|
|
966
|
-
f !== L.Connected && ((
|
|
976
|
+
f !== L.Connected && ((p = a.onConnectionStateChange) == null || p.call(a, f));
|
|
967
977
|
}, I.ontrack = (f) => {
|
|
968
|
-
var
|
|
969
|
-
i("peerConnection.ontrack", f), i("CALLBACK: onSrcObjectReady"), (
|
|
978
|
+
var p;
|
|
979
|
+
i("peerConnection.ontrack", f), i("CALLBACK: onSrcObjectReady"), (p = a.onSrcObjectReady) == null || p.call(a, f.streams[0]);
|
|
970
980
|
}, await I.setRemoteDescription(q), i("set remote description OK");
|
|
971
981
|
const z = await I.createAnswer();
|
|
972
|
-
i("create answer OK"), await I.setLocalDescription(z), i("set local description OK"), await k(_, z,
|
|
982
|
+
i("create answer OK"), await I.setLocalDescription(z), i("set local description OK"), await k(_, z, V, n), i("start connection OK");
|
|
973
983
|
function F(f) {
|
|
974
|
-
var
|
|
984
|
+
var p, b;
|
|
975
985
|
if (!m || Y.readyState !== "open") {
|
|
976
|
-
i("Data channel is not ready for sending messages"), (
|
|
986
|
+
i("Data channel is not ready for sending messages"), (p = a.onError) == null || p.call(a, new Error("Data channel is not ready for sending messages"), {
|
|
977
987
|
streamId: _
|
|
978
988
|
});
|
|
979
989
|
return;
|
|
@@ -990,7 +1000,7 @@ async function Ht(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = de,
|
|
|
990
1000
|
* @param payload
|
|
991
1001
|
*/
|
|
992
1002
|
speak(f) {
|
|
993
|
-
return B(_,
|
|
1003
|
+
return B(_, V, f);
|
|
994
1004
|
},
|
|
995
1005
|
/**
|
|
996
1006
|
* Method to close RTC connection
|
|
@@ -998,16 +1008,16 @@ async function Ht(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = de,
|
|
|
998
1008
|
async disconnect() {
|
|
999
1009
|
var f;
|
|
1000
1010
|
if (_) {
|
|
1001
|
-
const
|
|
1011
|
+
const p = be(I.iceConnectionState);
|
|
1002
1012
|
if (I) {
|
|
1003
|
-
if (
|
|
1013
|
+
if (p === L.New) {
|
|
1004
1014
|
g.stop();
|
|
1005
1015
|
return;
|
|
1006
1016
|
}
|
|
1007
1017
|
I.close(), I.oniceconnectionstatechange = null, I.onnegotiationneeded = null, I.onicecandidate = null, I.ontrack = null;
|
|
1008
1018
|
}
|
|
1009
1019
|
try {
|
|
1010
|
-
|
|
1020
|
+
p === L.Connected && await M(_, V).catch((b) => {
|
|
1011
1021
|
});
|
|
1012
1022
|
} catch (b) {
|
|
1013
1023
|
i("Error on close stream connection", b);
|
|
@@ -1019,27 +1029,27 @@ async function Ht(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = de,
|
|
|
1019
1029
|
/**
|
|
1020
1030
|
* Session identifier information, should be returned in the body of all streaming requests
|
|
1021
1031
|
*/
|
|
1022
|
-
sessionId:
|
|
1032
|
+
sessionId: V,
|
|
1023
1033
|
/**
|
|
1024
1034
|
* Id of current RTC stream
|
|
1025
1035
|
*/
|
|
1026
1036
|
streamId: _,
|
|
1027
|
-
streamType:
|
|
1037
|
+
streamType: K,
|
|
1028
1038
|
interruptAvailable: O ?? !1,
|
|
1029
1039
|
isInterruptible: !0,
|
|
1030
1040
|
interrupt(f) {
|
|
1031
1041
|
if (!O)
|
|
1032
1042
|
throw new Error("Interrupt is not enabled for this stream");
|
|
1033
|
-
if (
|
|
1043
|
+
if (K !== W.Fluent)
|
|
1034
1044
|
throw new Error("Interrupt only available for Fluent streams");
|
|
1035
|
-
if (!
|
|
1045
|
+
if (!w)
|
|
1036
1046
|
throw new Error("No active video to interrupt");
|
|
1037
|
-
const
|
|
1047
|
+
const p = {
|
|
1038
1048
|
type: P.StreamInterrupt,
|
|
1039
|
-
videoId:
|
|
1049
|
+
videoId: w,
|
|
1040
1050
|
timestamp: Date.now()
|
|
1041
1051
|
};
|
|
1042
|
-
F(JSON.stringify(
|
|
1052
|
+
F(JSON.stringify(p));
|
|
1043
1053
|
}
|
|
1044
1054
|
};
|
|
1045
1055
|
}
|
|
@@ -1055,7 +1065,7 @@ async function qt(e, t, r, a) {
|
|
|
1055
1065
|
const { version: s, ...o } = t;
|
|
1056
1066
|
switch (o.transport.provider) {
|
|
1057
1067
|
case he.Livekit:
|
|
1058
|
-
const { createLiveKitStreamingManager: n } = await import("./livekit-manager-
|
|
1068
|
+
const { createLiveKitStreamingManager: n } = await import("./livekit-manager-B7gYoJ6B.js");
|
|
1059
1069
|
return n(c, o, r);
|
|
1060
1070
|
default:
|
|
1061
1071
|
throw new Error(`Unsupported transport provider: ${o.transport.provider}`);
|
|
@@ -1173,23 +1183,23 @@ function Le(e, t, r, a) {
|
|
|
1173
1183
|
analytics: r,
|
|
1174
1184
|
callbacks: {
|
|
1175
1185
|
...t.callbacks,
|
|
1176
|
-
onConnectionStateChange: (l,
|
|
1186
|
+
onConnectionStateChange: (l, h) => {
|
|
1177
1187
|
var v, k;
|
|
1178
|
-
(k = (v = t.callbacks).onConnectionStateChange) == null || k.call(v, l), Zt(l,
|
|
1188
|
+
(k = (v = t.callbacks).onConnectionStateChange) == null || k.call(v, l), Zt(l, h, r), l === L.Connected && (o ? c(o) : n = !0);
|
|
1179
1189
|
},
|
|
1180
|
-
onVideoStateChange: (l,
|
|
1190
|
+
onVideoStateChange: (l, h) => {
|
|
1181
1191
|
var v, k;
|
|
1182
1192
|
(k = (v = t.callbacks).onVideoStateChange) == null || k.call(v, l), er(
|
|
1183
1193
|
l,
|
|
1184
1194
|
e,
|
|
1185
|
-
|
|
1195
|
+
h,
|
|
1186
1196
|
r,
|
|
1187
1197
|
o.streamType
|
|
1188
1198
|
);
|
|
1189
1199
|
},
|
|
1190
1200
|
onAgentActivityStateChange: (l) => {
|
|
1191
|
-
var
|
|
1192
|
-
(v = (
|
|
1201
|
+
var h, v;
|
|
1202
|
+
(v = (h = t.callbacks).onAgentActivityStateChange) == null || v.call(h, l), l === ne.Talking ? (fe.update(), d = (k) => {
|
|
1193
1203
|
xe(
|
|
1194
1204
|
S.Start,
|
|
1195
1205
|
e,
|
|
@@ -1211,9 +1221,9 @@ function Le(e, t, r, a) {
|
|
|
1211
1221
|
const l = Te.get(!0);
|
|
1212
1222
|
r.track("agent-chat", { event: "ready", latency: l });
|
|
1213
1223
|
},
|
|
1214
|
-
onToolEvent: (l,
|
|
1224
|
+
onToolEvent: (l, h) => {
|
|
1215
1225
|
var v, k;
|
|
1216
|
-
(k = (v = t.callbacks).onToolEvent) == null || k.call(v, l,
|
|
1226
|
+
(k = (v = t.callbacks).onToolEvent) == null || k.call(v, l, h), nr(l, h, r);
|
|
1217
1227
|
}
|
|
1218
1228
|
}
|
|
1219
1229
|
},
|
|
@@ -1225,7 +1235,7 @@ function Le(e, t, r, a) {
|
|
|
1225
1235
|
});
|
|
1226
1236
|
}
|
|
1227
1237
|
async function ar(e, t, r, a, c) {
|
|
1228
|
-
var m, l,
|
|
1238
|
+
var m, l, h, v;
|
|
1229
1239
|
const s = async () => {
|
|
1230
1240
|
if (pe(e.presenter.type)) {
|
|
1231
1241
|
const k = await Le(e, t, a), B = `${Xt}_${k.sessionId}`, M = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -1262,10 +1272,10 @@ async function ar(e, t, r, a, c) {
|
|
|
1262
1272
|
}
|
|
1263
1273
|
}
|
|
1264
1274
|
}, { chatResult: o, streamingManager: n } = await s(), { chat: i, chatMode: d } = o;
|
|
1265
|
-
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) ? ((v = (
|
|
1275
|
+
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) ? ((v = (h = t.callbacks).onError) == null || v.call(h, new He(d)), n == null || n.disconnect(), { chat: i }) : { chat: i, streamingManager: n };
|
|
1266
1276
|
}
|
|
1267
1277
|
async function dr(e, t) {
|
|
1268
|
-
var Y,
|
|
1278
|
+
var Y, K, ae, ie;
|
|
1269
1279
|
let r = !0;
|
|
1270
1280
|
const a = t.mixpanelKey || ot, c = t.wsURL || st, s = t.baseURL || de, o = t.mode || x.Functional, n = {
|
|
1271
1281
|
messages: [],
|
|
@@ -1282,17 +1292,17 @@ async function dr(e, t) {
|
|
|
1282
1292
|
});
|
|
1283
1293
|
const m = wt(t.auth, s, t.callbacks.onError, t.externalId), l = await m.getById(e);
|
|
1284
1294
|
t.debug = t.debug || ((Y = l == null ? void 0 : l.advanced_settings) == null ? void 0 : Y.ui_debug_mode);
|
|
1285
|
-
const
|
|
1295
|
+
const h = pe(l.presenter.type);
|
|
1286
1296
|
i.enrich(yt(l));
|
|
1287
1297
|
const { onMessage: v, clearQueue: k } = xt(i, n, t, l, () => {
|
|
1288
|
-
var u, g,
|
|
1289
|
-
(u = n.socketManager) == null || u.disconnect(), (
|
|
1298
|
+
var u, g, w;
|
|
1299
|
+
(u = n.socketManager) == null || u.disconnect(), (w = (g = t.callbacks).onConnectionStateChange) == null || w.call(g, L.Disconnected);
|
|
1290
1300
|
});
|
|
1291
|
-
n.messages = It(t.initialMessages), (ae = (
|
|
1301
|
+
n.messages = It(t.initialMessages), (ae = (K = t.callbacks).onNewMessage) == null || ae.call(K, [...n.messages], "answer");
|
|
1292
1302
|
const B = (u) => {
|
|
1293
1303
|
}, M = ({ type: u }) => {
|
|
1294
|
-
var
|
|
1295
|
-
if (!((
|
|
1304
|
+
var w, y, C, R;
|
|
1305
|
+
if (!((w = n.streamingManager) != null && w.interruptAvailable) || !((y = n.streamingManager) != null && y.isInterruptible)) return;
|
|
1296
1306
|
const g = n.messages[n.messages.length - 1];
|
|
1297
1307
|
i.track("agent-video-interrupt", {
|
|
1298
1308
|
type: u || "click",
|
|
@@ -1302,44 +1312,44 @@ async function dr(e, t) {
|
|
|
1302
1312
|
}, D = /* @__PURE__ */ new Map();
|
|
1303
1313
|
function $(u) {
|
|
1304
1314
|
return async (g) => {
|
|
1305
|
-
const
|
|
1306
|
-
if (!
|
|
1315
|
+
const w = D.get(u);
|
|
1316
|
+
if (!w)
|
|
1307
1317
|
throw new Error(`No handler registered for client tool: ${u}`);
|
|
1308
1318
|
try {
|
|
1309
1319
|
const y = JSON.parse(g.payload);
|
|
1310
|
-
return await
|
|
1320
|
+
return await w(y);
|
|
1311
1321
|
} catch (y) {
|
|
1312
1322
|
throw new Error(`Client tool "${u}" failed: ${y.message}`);
|
|
1313
1323
|
}
|
|
1314
1324
|
};
|
|
1315
1325
|
}
|
|
1316
1326
|
function _() {
|
|
1317
|
-
var u, g,
|
|
1327
|
+
var u, g, w, y;
|
|
1318
1328
|
for (const [C] of D)
|
|
1319
|
-
(g = (u = n.streamingManager) == null ? void 0 : u.unregisterRpcMethod) == null || g.call(u, C), (y = (
|
|
1329
|
+
(g = (u = n.streamingManager) == null ? void 0 : u.unregisterRpcMethod) == null || g.call(u, C), (y = (w = n.streamingManager) == null ? void 0 : w.registerRpcMethod) == null || y.call(w, C, $(C));
|
|
1320
1330
|
}
|
|
1321
1331
|
function q(u, g) {
|
|
1322
1332
|
var y, C;
|
|
1323
|
-
const
|
|
1324
|
-
D.set(u, g),
|
|
1333
|
+
const w = !D.has(u);
|
|
1334
|
+
D.set(u, g), w && ((C = (y = n.streamingManager) == null ? void 0 : y.registerRpcMethod) == null || C.call(y, u, $(u)));
|
|
1325
1335
|
}
|
|
1326
1336
|
function J(u) {
|
|
1327
|
-
var g,
|
|
1328
|
-
D.delete(u), (
|
|
1337
|
+
var g, w;
|
|
1338
|
+
D.delete(u), (w = (g = n.streamingManager) == null ? void 0 : g.unregisterRpcMethod) == null || w.call(g, u);
|
|
1329
1339
|
}
|
|
1330
|
-
const
|
|
1340
|
+
const V = Date.now();
|
|
1331
1341
|
Ee(() => {
|
|
1332
|
-
i.track("agent-sdk", { event: "loaded", ...vt(l) },
|
|
1342
|
+
i.track("agent-sdk", { event: "loaded", ...vt(l) }, V);
|
|
1333
1343
|
});
|
|
1334
1344
|
async function X(u) {
|
|
1335
|
-
var j, z, F, E, f,
|
|
1345
|
+
var j, z, F, E, f, p, b;
|
|
1336
1346
|
(z = (j = t.callbacks).onConnectionStateChange) == null || z.call(j, L.Connecting), H.reset(), u && !r && (delete n.chat, (E = (F = t.callbacks).onNewMessage) == null || E.call(F, [...n.messages], "answer"));
|
|
1337
|
-
const g = o === x.DirectPlayback ||
|
|
1347
|
+
const g = o === x.DirectPlayback || h ? Promise.resolve(void 0) : Tt(
|
|
1338
1348
|
t.auth,
|
|
1339
1349
|
c,
|
|
1340
1350
|
{ onMessage: v, onError: t.callbacks.onError },
|
|
1341
1351
|
t.externalId
|
|
1342
|
-
),
|
|
1352
|
+
), w = ue(
|
|
1343
1353
|
() => ar(
|
|
1344
1354
|
l,
|
|
1345
1355
|
{
|
|
@@ -1363,22 +1373,22 @@ async function dr(e, t) {
|
|
|
1363
1373
|
delayMs: 1e3
|
|
1364
1374
|
}
|
|
1365
1375
|
).catch((T) => {
|
|
1366
|
-
var A,
|
|
1367
|
-
throw I(x.Maintenance), (
|
|
1368
|
-
}), [y, { streamingManager: C, chat: R }] = await Promise.all([g,
|
|
1369
|
-
R && R.id !== ((f = n.chat) == null ? void 0 : f.id) && ((b = (
|
|
1376
|
+
var A, U;
|
|
1377
|
+
throw I(x.Maintenance), (U = (A = t.callbacks).onConnectionStateChange) == null || U.call(A, L.Fail), T;
|
|
1378
|
+
}), [y, { streamingManager: C, chat: R }] = await Promise.all([g, w]);
|
|
1379
|
+
R && R.id !== ((f = n.chat) == null ? void 0 : f.id) && ((b = (p = t.callbacks).onNewChat) == null || b.call(p, R.id)), n.streamingManager = C, n.socketManager = y, n.chat = R, _(), r = !1, i.enrich({
|
|
1370
1380
|
chatId: R == null ? void 0 : R.id,
|
|
1371
1381
|
streamId: C == null ? void 0 : C.streamId,
|
|
1372
1382
|
mode: n.chatMode
|
|
1373
1383
|
}), I((R == null ? void 0 : R.chat_mode) ?? o);
|
|
1374
1384
|
}
|
|
1375
1385
|
async function O() {
|
|
1376
|
-
var u, g,
|
|
1377
|
-
(u = n.socketManager) == null || u.disconnect(), await ((g = n.streamingManager) == null ? void 0 : g.disconnect()), delete n.streamingManager, delete n.socketManager, (y = (
|
|
1386
|
+
var u, g, w, y;
|
|
1387
|
+
(u = n.socketManager) == null || u.disconnect(), await ((g = n.streamingManager) == null ? void 0 : g.disconnect()), delete n.streamingManager, delete n.socketManager, (y = (w = t.callbacks).onConnectionStateChange) == null || y.call(w, L.Disconnected);
|
|
1378
1388
|
}
|
|
1379
1389
|
async function I(u) {
|
|
1380
|
-
var g,
|
|
1381
|
-
u !== n.chatMode && (i.track("agent-mode-change", { mode: u }), n.chatMode = u, n.chatMode !== x.Functional && await O(), (
|
|
1390
|
+
var g, w;
|
|
1391
|
+
u !== n.chatMode && (i.track("agent-mode-change", { mode: u }), n.chatMode = u, n.chatMode !== x.Functional && await O(), (w = (g = t.callbacks).onModeChange) == null || w.call(g, u));
|
|
1382
1392
|
}
|
|
1383
1393
|
return {
|
|
1384
1394
|
agent: l,
|
|
@@ -1402,7 +1412,7 @@ async function dr(e, t) {
|
|
|
1402
1412
|
},
|
|
1403
1413
|
async reconnect() {
|
|
1404
1414
|
const u = n.streamingManager;
|
|
1405
|
-
if (
|
|
1415
|
+
if (h && (u != null && u.reconnect)) {
|
|
1406
1416
|
try {
|
|
1407
1417
|
await u.reconnect(), i.track("agent-chat", {
|
|
1408
1418
|
event: "reconnect",
|
|
@@ -1461,35 +1471,35 @@ async function dr(e, t) {
|
|
|
1461
1471
|
if (!n.chat)
|
|
1462
1472
|
throw new G("Chat is not initialized");
|
|
1463
1473
|
}
|
|
1464
|
-
},
|
|
1474
|
+
}, w = async () => {
|
|
1465
1475
|
var E, f;
|
|
1466
1476
|
if (!n.chat) {
|
|
1467
|
-
const
|
|
1477
|
+
const p = await Ve(
|
|
1468
1478
|
l,
|
|
1469
1479
|
m,
|
|
1470
1480
|
i,
|
|
1471
1481
|
n.chatMode,
|
|
1472
1482
|
t.persistentChat
|
|
1473
1483
|
);
|
|
1474
|
-
if (!
|
|
1484
|
+
if (!p.chat)
|
|
1475
1485
|
throw new Oe(n.chatMode, !!t.persistentChat);
|
|
1476
|
-
n.chat =
|
|
1486
|
+
n.chat = p.chat, (f = (E = t.callbacks).onNewChat) == null || f.call(E, n.chat.id);
|
|
1477
1487
|
}
|
|
1478
1488
|
return n.chat.id;
|
|
1479
1489
|
}, y = async (E, f) => {
|
|
1480
|
-
const
|
|
1481
|
-
return ue(
|
|
1482
|
-
var A,
|
|
1483
|
-
return await ((
|
|
1490
|
+
const p = n.chatMode === x.Playground;
|
|
1491
|
+
return ue(h && !p ? async () => {
|
|
1492
|
+
var A, U;
|
|
1493
|
+
return await ((U = (A = n.streamingManager) == null ? void 0 : A.sendTextMessage) == null ? void 0 : U.call(A, u)), Promise.resolve({});
|
|
1484
1494
|
} : async () => {
|
|
1485
|
-
var A,
|
|
1495
|
+
var A, U;
|
|
1486
1496
|
return m.chat(
|
|
1487
1497
|
l.id,
|
|
1488
1498
|
f,
|
|
1489
1499
|
{
|
|
1490
1500
|
chatMode: n.chatMode,
|
|
1491
1501
|
streamId: (A = n.streamingManager) == null ? void 0 : A.streamId,
|
|
1492
|
-
sessionId: (
|
|
1502
|
+
sessionId: (U = n.streamingManager) == null ? void 0 : U.sessionId,
|
|
1493
1503
|
messages: E.map(({ matches: Ue, ...se }) => se)
|
|
1494
1504
|
},
|
|
1495
1505
|
{
|
|
@@ -1501,8 +1511,8 @@ async function dr(e, t) {
|
|
|
1501
1511
|
limit: 2,
|
|
1502
1512
|
shouldRetryFn: (A) => {
|
|
1503
1513
|
var se, ve, ye, Ce;
|
|
1504
|
-
const
|
|
1505
|
-
return !((ve = A == null ? void 0 : A.message) == null ? void 0 : ve.includes("Stream Error")) && !
|
|
1514
|
+
const U = (se = A == null ? void 0 : A.message) == null ? void 0 : se.includes("missing or invalid session_id");
|
|
1515
|
+
return !((ve = A == null ? void 0 : A.message) == null ? void 0 : ve.includes("Stream Error")) && !U ? ((Ce = (ye = t.callbacks).onError) == null || Ce.call(ye, A), !1) : !0;
|
|
1506
1516
|
},
|
|
1507
1517
|
onRetry: async () => {
|
|
1508
1518
|
await O(), await X(!1);
|
|
@@ -1517,12 +1527,12 @@ async function dr(e, t) {
|
|
|
1517
1527
|
parts: re(u),
|
|
1518
1528
|
created_at: new Date(H.update()).toISOString()
|
|
1519
1529
|
}), (R = (C = t.callbacks).onNewMessage) == null || R.call(C, [...n.messages], "user");
|
|
1520
|
-
const E = await
|
|
1521
|
-
return n.messages.push({
|
|
1530
|
+
const E = await w(), f = await y([...n.messages], E);
|
|
1531
|
+
return f.result && n.messages.push({
|
|
1522
1532
|
id: Q(),
|
|
1523
1533
|
role: "assistant",
|
|
1524
|
-
content: f.result
|
|
1525
|
-
parts: re(f.result
|
|
1534
|
+
content: f.result,
|
|
1535
|
+
parts: re(f.result),
|
|
1526
1536
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1527
1537
|
context: f.context,
|
|
1528
1538
|
matches: f.matches
|
|
@@ -1540,7 +1550,7 @@ async function dr(e, t) {
|
|
|
1540
1550
|
}), E;
|
|
1541
1551
|
}
|
|
1542
1552
|
},
|
|
1543
|
-
rate(u, g,
|
|
1553
|
+
rate(u, g, w) {
|
|
1544
1554
|
var R, j, z, F;
|
|
1545
1555
|
const y = n.messages.find((E) => E.id === u);
|
|
1546
1556
|
if (n.chat) {
|
|
@@ -1549,12 +1559,12 @@ async function dr(e, t) {
|
|
|
1549
1559
|
} else throw new Error("Chat is not initialized");
|
|
1550
1560
|
const C = ((R = y.matches) == null ? void 0 : R.map((E) => [E.document_id, E.id])) ?? [];
|
|
1551
1561
|
return i.track("agent-rate", {
|
|
1552
|
-
event:
|
|
1562
|
+
event: w ? "update" : "create",
|
|
1553
1563
|
thumb: g === 1 ? "up" : "down",
|
|
1554
1564
|
knowledge_id: ((j = l.knowledge) == null ? void 0 : j.id) ?? "",
|
|
1555
1565
|
matches: C,
|
|
1556
1566
|
score: g
|
|
1557
|
-
}),
|
|
1567
|
+
}), w ? m.updateRating(l.id, n.chat.id, w, {
|
|
1558
1568
|
knowledge_id: ((z = l.knowledge) == null ? void 0 : z.id) ?? "",
|
|
1559
1569
|
message_id: u,
|
|
1560
1570
|
matches: C,
|
|
@@ -1596,12 +1606,12 @@ async function dr(e, t) {
|
|
|
1596
1606
|
}
|
|
1597
1607
|
return u;
|
|
1598
1608
|
}
|
|
1599
|
-
const
|
|
1600
|
-
if (i.track("agent-speak",
|
|
1609
|
+
const w = g();
|
|
1610
|
+
if (i.track("agent-speak", w), H.update(), n.messages && w.type === "text" && (n.messages.push({
|
|
1601
1611
|
id: Q(),
|
|
1602
1612
|
role: "assistant",
|
|
1603
|
-
content:
|
|
1604
|
-
parts: re(
|
|
1613
|
+
content: w.input,
|
|
1614
|
+
parts: re(w.input),
|
|
1605
1615
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1606
1616
|
}), (R = (C = t.callbacks).onNewMessage) == null || R.call(C, [...n.messages], "answer")), lt(n.chatMode))
|
|
1607
1617
|
return {
|
|
@@ -1612,7 +1622,7 @@ async function dr(e, t) {
|
|
|
1612
1622
|
if (!n.streamingManager)
|
|
1613
1623
|
throw new Error("Please connect to the agent first");
|
|
1614
1624
|
return n.streamingManager.speak({
|
|
1615
|
-
script:
|
|
1625
|
+
script: w,
|
|
1616
1626
|
metadata: { chat_id: (j = n.chat) == null ? void 0 : j.id, agent_id: l.id }
|
|
1617
1627
|
});
|
|
1618
1628
|
},
|
|
@@ -1623,7 +1633,7 @@ async function dr(e, t) {
|
|
|
1623
1633
|
}
|
|
1624
1634
|
export {
|
|
1625
1635
|
ne as A,
|
|
1626
|
-
|
|
1636
|
+
N as C,
|
|
1627
1637
|
tt as D,
|
|
1628
1638
|
et as K,
|
|
1629
1639
|
Ye as P,
|