@d-id/client-sdk 1.1.17-staging.76 → 1.1.17-staging.77
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-BhpiSVbj.js → index-DKb-cXkg.js} +93 -90
- package/dist/index.js +1 -1
- package/dist/index.umd.cjs +6 -6
- package/dist/livekit-manager-D7QkEucf.js +195 -0
- package/dist/src/services/agent-manager/connect-to-manager.d.ts +3 -1
- package/dist/src/types/stream/stream.d.ts +2 -1
- package/package.json +1 -1
- package/dist/livekit-manager-C6I2lSHF.js +0 -198
|
@@ -42,12 +42,14 @@ const bt = (e) => {
|
|
|
42
42
|
return "clip";
|
|
43
43
|
case "talk":
|
|
44
44
|
return "talk";
|
|
45
|
+
case "expressive":
|
|
46
|
+
return "expressive";
|
|
45
47
|
default:
|
|
46
48
|
throw new Error(`Unknown video type: ${e}`);
|
|
47
49
|
}
|
|
48
50
|
};
|
|
49
|
-
var w = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(w || {}), Z = /* @__PURE__ */ ((e) => (e.Strong = "STRONG", e.Weak = "WEAK", e.Unknown = "UNKNOWN", e))(Z || {}), O = /* @__PURE__ */ ((e) => (e.Idle = "IDLE", e.Talking = "TALKING", e))(O || {}), P = /* @__PURE__ */ ((e) => (e.ChatAnswer = "chat/answer", e.ChatPartial = "chat/partial", e.StreamDone = "stream/done", e.StreamStarted = "stream/started", e.StreamFailed = "stream/error", e.StreamReady = "stream/ready", e.StreamCreated = "stream/created", e.StreamInterrupt = "stream/interrupt", e.StreamVideoCreated = "stream-video/started", e.StreamVideoDone = "stream-video/done", e.StreamVideoError = "stream-video/error", e.StreamVideoRejected = "stream-video/rejected", e))(P || {}), I = /* @__PURE__ */ ((e) => (e.New = "new", e.Fail = "fail", e.Connected = "connected", e.Connecting = "connecting", e.Closed = "closed", e.Completed = "completed", e.Disconnected = "disconnected", e))(I || {}), W = /* @__PURE__ */ ((e) => (e.Legacy = "legacy", e.Fluent = "fluent", e))(W || {}), de = /* @__PURE__ */ ((e) => (e.Livekit = "livekit", e))(de || {}),
|
|
50
|
-
const
|
|
51
|
+
var w = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(w || {}), Z = /* @__PURE__ */ ((e) => (e.Strong = "STRONG", e.Weak = "WEAK", e.Unknown = "UNKNOWN", e))(Z || {}), O = /* @__PURE__ */ ((e) => (e.Idle = "IDLE", e.Talking = "TALKING", e))(O || {}), P = /* @__PURE__ */ ((e) => (e.ChatAnswer = "chat/answer", e.ChatPartial = "chat/partial", e.StreamDone = "stream/done", e.StreamStarted = "stream/started", e.StreamFailed = "stream/error", e.StreamReady = "stream/ready", e.StreamCreated = "stream/created", e.StreamInterrupt = "stream/interrupt", e.StreamVideoCreated = "stream-video/started", e.StreamVideoDone = "stream-video/done", e.StreamVideoError = "stream-video/error", e.StreamVideoRejected = "stream-video/rejected", e))(P || {}), I = /* @__PURE__ */ ((e) => (e.New = "new", e.Fail = "fail", e.Connected = "connected", e.Connecting = "connecting", e.Closed = "closed", e.Completed = "completed", e.Disconnected = "disconnected", e))(I || {}), W = /* @__PURE__ */ ((e) => (e.Legacy = "legacy", e.Fluent = "fluent", e))(W || {}), de = /* @__PURE__ */ ((e) => (e.Livekit = "livekit", e))(de || {}), xe = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.AzureOpenAi = "azure-openai", e.Microsoft = "microsoft", e.Afflorithmics = "afflorithmics", e.Elevenlabs = "elevenlabs", e))(xe || {}), Be = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e))(Be || {});
|
|
52
|
+
const $e = 45 * 1e3, ze = "X-Playground-Chat", te = "https://api.d-id.com", Fe = "wss://notifications.d-id.com", Ne = "79f81a83a67430be2bc0fd61042b8faa", we = (e) => new Promise((t) => setTimeout(t, e)), q = (e = 16) => {
|
|
51
53
|
const t = new Uint8Array(e);
|
|
52
54
|
return window.crypto.getRandomValues(t), Array.from(t, (a) => a.toString(16).padStart(2, "0")).join("").slice(0, 13);
|
|
53
55
|
}, pe = (e) => e.type === "clip" && e.presenter_id.startsWith("v2_") ? "clip_v2" : e.type, le = (e) => e === he.Expressive, Je = (e) => [_.TextOnly, _.Playground, _.Maintenance].includes(e), ve = (e) => e && [_.DirectPlayback, _.Off].includes(e);
|
|
@@ -357,10 +359,10 @@ async function et(e, t) {
|
|
|
357
359
|
function tt(e) {
|
|
358
360
|
return new Promise((t, a) => {
|
|
359
361
|
const { callbacks: r, host: o, auth: i, externalId: c } = e, { onMessage: n = null, onOpen: s = null, onClose: d = null, onError: l = null } = r || {}, h = new WebSocket(`${o}?authorization=${encodeURIComponent(ye(i, c))}`);
|
|
360
|
-
h.onmessage = n, h.onclose = d, h.onerror = (
|
|
361
|
-
console.error(
|
|
362
|
-
}, h.onopen = (
|
|
363
|
-
s == null || s(
|
|
362
|
+
h.onmessage = n, h.onclose = d, h.onerror = (y) => {
|
|
363
|
+
console.error(y), l == null || l("Websocket failed to connect", y), a(y);
|
|
364
|
+
}, h.onopen = (y) => {
|
|
365
|
+
s == null || s(y), t(h);
|
|
364
366
|
};
|
|
365
367
|
});
|
|
366
368
|
}
|
|
@@ -428,14 +430,14 @@ function st(e, t, a, r, o) {
|
|
|
428
430
|
mode: t.chatMode
|
|
429
431
|
});
|
|
430
432
|
else {
|
|
431
|
-
const l = P, h = [l.StreamVideoDone, l.StreamVideoError, l.StreamVideoRejected],
|
|
433
|
+
const l = P, h = [l.StreamVideoDone, l.StreamVideoError, l.StreamVideoRejected], y = [l.StreamFailed, l.StreamVideoError, l.StreamVideoRejected], b = Xe(n, r, { mode: t.chatMode });
|
|
432
434
|
if (c = c, c === l.StreamVideoCreated)
|
|
433
435
|
e.linkTrack("agent-video", b, l.StreamVideoCreated, ["start"]);
|
|
434
436
|
else if (h.includes(c)) {
|
|
435
437
|
const L = c.split("/")[1];
|
|
436
|
-
|
|
438
|
+
y.includes(c) ? e.track("agent-video", { ...b, event: L }) : e.linkTrack("agent-video", { ...b, event: L }, c, ["done"]);
|
|
437
439
|
}
|
|
438
|
-
|
|
440
|
+
y.includes(c) && ((d = (s = a.callbacks).onError) == null || d.call(s, new Error(`Stream failed with event ${c}`), { data: n })), n.event === l.StreamDone && o();
|
|
439
441
|
}
|
|
440
442
|
}
|
|
441
443
|
};
|
|
@@ -618,15 +620,15 @@ function wt() {
|
|
|
618
620
|
};
|
|
619
621
|
}
|
|
620
622
|
function pt(e, t, a, r, o) {
|
|
621
|
-
let i = [], c, n = 0, s = !1, d = Z.Unknown, l = Z.Unknown, h = 0,
|
|
623
|
+
let i = [], c, n = 0, s = !1, d = Z.Unknown, l = Z.Unknown, h = 0, y = 0;
|
|
622
624
|
const b = wt();
|
|
623
625
|
return setInterval(async () => {
|
|
624
|
-
const L = await e.getStats(), { isReceiving:
|
|
625
|
-
if (
|
|
626
|
-
n = 0, h =
|
|
626
|
+
const L = await e.getStats(), { isReceiving: x, avgJitterDelayInInterval: j, freezeCount: B } = b(L), D = ut(L);
|
|
627
|
+
if (x)
|
|
628
|
+
n = 0, h = B - y, l = j < gt ? Z.Strong : j > ht && h > 1 ? Z.Weak : d, l !== d && (o == null || o(l), d = l, y += h, h = 0), s || (r == null || r(w.Start), c = i[i.length - 1], i = [], s = !0), i.push(D);
|
|
627
629
|
else if (s && (n++, n >= mt)) {
|
|
628
630
|
const K = ft(i, oe, c);
|
|
629
|
-
r == null || r(w.Stop, K), t() || a(),
|
|
631
|
+
r == null || r(w.Stop, K), t() || a(), y = B, s = !1;
|
|
630
632
|
}
|
|
631
633
|
}, oe);
|
|
632
634
|
}
|
|
@@ -696,8 +698,8 @@ function me({
|
|
|
696
698
|
async function Ct(e, t, { debug: a = !1, callbacks: r, auth: o, baseURL: i = te, analytics: c }) {
|
|
697
699
|
var X;
|
|
698
700
|
const n = ct(a, "WebRTCStreamingManager"), s = yt(n);
|
|
699
|
-
let d = !1, l = !1, h = w.Stop,
|
|
700
|
-
const { startConnection: b, sendStreamRequest: L, close:
|
|
701
|
+
let d = !1, l = !1, h = w.Stop, y = w.Stop;
|
|
702
|
+
const { startConnection: b, sendStreamRequest: L, close: x, createStream: j, addIceCandidate: B } = ot(
|
|
701
703
|
o,
|
|
702
704
|
i,
|
|
703
705
|
e,
|
|
@@ -707,7 +709,7 @@ async function Ct(e, t, { debug: a = !1, callbacks: r, auth: o, baseURL: i = te,
|
|
|
707
709
|
offer: K,
|
|
708
710
|
ice_servers: G,
|
|
709
711
|
session_id: u,
|
|
710
|
-
fluent:
|
|
712
|
+
fluent: k,
|
|
711
713
|
interrupt_enabled: v,
|
|
712
714
|
triggers_enabled: T
|
|
713
715
|
} = await j(t);
|
|
@@ -715,11 +717,11 @@ async function Ct(e, t, { debug: a = !1, callbacks: r, auth: o, baseURL: i = te,
|
|
|
715
717
|
const g = new vt({ iceServers: G }), p = g.createDataChannel("JanusDataChannel");
|
|
716
718
|
if (!u)
|
|
717
719
|
throw new Error("Could not create session_id");
|
|
718
|
-
const S =
|
|
720
|
+
const S = k ? W.Fluent : W.Legacy;
|
|
719
721
|
c.enrich({
|
|
720
722
|
"stream-type": S
|
|
721
723
|
});
|
|
722
|
-
const
|
|
724
|
+
const $ = t.stream_warmup && !k, z = () => d, C = () => {
|
|
723
725
|
var f;
|
|
724
726
|
d = !0, l && ((f = r.onConnectionStateChange) == null || f.call(r, I.Connected));
|
|
725
727
|
}, E = pt(
|
|
@@ -727,7 +729,7 @@ async function Ct(e, t, { debug: a = !1, callbacks: r, auth: o, baseURL: i = te,
|
|
|
727
729
|
z,
|
|
728
730
|
C,
|
|
729
731
|
(f, m) => me({
|
|
730
|
-
statsSignal:
|
|
732
|
+
statsSignal: y = f,
|
|
731
733
|
dataChannelSignal: S === W.Legacy ? h : void 0,
|
|
732
734
|
onVideoStateChange: r.onVideoStateChange,
|
|
733
735
|
onAgentActivityStateChange: r.onAgentActivityStateChange,
|
|
@@ -743,7 +745,7 @@ async function Ct(e, t, { debug: a = !1, callbacks: r, auth: o, baseURL: i = te,
|
|
|
743
745
|
var m;
|
|
744
746
|
n("peerConnection.onicecandidate", f);
|
|
745
747
|
try {
|
|
746
|
-
f.candidate && f.candidate.sdpMid && f.candidate.sdpMLineIndex !== null ?
|
|
748
|
+
f.candidate && f.candidate.sdpMid && f.candidate.sdpMLineIndex !== null ? B(
|
|
747
749
|
D,
|
|
748
750
|
{
|
|
749
751
|
candidate: f.candidate.candidate,
|
|
@@ -751,24 +753,24 @@ async function Ct(e, t, { debug: a = !1, callbacks: r, auth: o, baseURL: i = te,
|
|
|
751
753
|
sdpMLineIndex: f.candidate.sdpMLineIndex
|
|
752
754
|
},
|
|
753
755
|
u
|
|
754
|
-
) :
|
|
756
|
+
) : B(D, { candidate: null }, u);
|
|
755
757
|
} catch (A) {
|
|
756
758
|
(m = r.onError) == null || m.call(r, A, { streamId: D });
|
|
757
759
|
}
|
|
758
760
|
}, p.onopen = () => {
|
|
759
|
-
l = !0, (
|
|
761
|
+
l = !0, (!$ || d) && C();
|
|
760
762
|
};
|
|
761
763
|
const J = (f) => {
|
|
762
764
|
var m;
|
|
763
765
|
(m = r.onVideoIdChange) == null || m.call(r, f);
|
|
764
766
|
};
|
|
765
|
-
function
|
|
767
|
+
function R(f, m) {
|
|
766
768
|
if (f === P.StreamStarted && typeof m == "object" && "metadata" in m) {
|
|
767
769
|
const A = m.metadata;
|
|
768
770
|
J(A.videoId);
|
|
769
771
|
}
|
|
770
772
|
f === P.StreamDone && J(null), h = f === P.StreamStarted ? w.Start : w.Stop, me({
|
|
771
|
-
statsSignal: S === W.Legacy ?
|
|
773
|
+
statsSignal: S === W.Legacy ? y : void 0,
|
|
772
774
|
dataChannelSignal: h,
|
|
773
775
|
onVideoStateChange: r.onVideoStateChange,
|
|
774
776
|
onAgentActivityStateChange: r.onAgentActivityStateChange,
|
|
@@ -780,8 +782,8 @@ async function Ct(e, t, { debug: a = !1, callbacks: r, auth: o, baseURL: i = te,
|
|
|
780
782
|
A && c.enrich({ streamMetadata: A }), c.track("agent-chat", { event: "ready" });
|
|
781
783
|
}
|
|
782
784
|
const U = {
|
|
783
|
-
[P.StreamStarted]:
|
|
784
|
-
[P.StreamDone]:
|
|
785
|
+
[P.StreamStarted]: R,
|
|
786
|
+
[P.StreamDone]: R,
|
|
785
787
|
[P.StreamReady]: M
|
|
786
788
|
};
|
|
787
789
|
p.onmessage = (f) => {
|
|
@@ -821,7 +823,7 @@ async function Ct(e, t, { debug: a = !1, callbacks: r, auth: o, baseURL: i = te,
|
|
|
821
823
|
g.close(), g.oniceconnectionstatechange = null, g.onnegotiationneeded = null, g.onicecandidate = null, g.ontrack = null;
|
|
822
824
|
}
|
|
823
825
|
try {
|
|
824
|
-
m === I.Connected && await
|
|
826
|
+
m === I.Connected && await x(D, u).catch((A) => {
|
|
825
827
|
});
|
|
826
828
|
} catch (A) {
|
|
827
829
|
n("Error on close stream connection", A);
|
|
@@ -871,7 +873,7 @@ async function Dt(e, t, a) {
|
|
|
871
873
|
const { version: o, ...i } = t;
|
|
872
874
|
switch (i.transport_provider) {
|
|
873
875
|
case de.Livekit:
|
|
874
|
-
const { createLiveKitStreamingManager: c } = await import("./livekit-manager-
|
|
876
|
+
const { createLiveKitStreamingManager: c } = await import("./livekit-manager-D7QkEucf.js");
|
|
875
877
|
return c(r, i, a);
|
|
876
878
|
default:
|
|
877
879
|
throw new Error(`Unsupported transport provider: ${i.transport_provider}`);
|
|
@@ -992,11 +994,11 @@ function ge(e, t, a) {
|
|
|
992
994
|
});
|
|
993
995
|
}
|
|
994
996
|
async function jt(e, t, a, r, o) {
|
|
995
|
-
var l, h,
|
|
997
|
+
var l, h, y, b;
|
|
996
998
|
const i = async () => {
|
|
997
999
|
var L;
|
|
998
1000
|
if (le(e.presenter.type)) {
|
|
999
|
-
const
|
|
1001
|
+
const x = await se(
|
|
1000
1002
|
e,
|
|
1001
1003
|
a,
|
|
1002
1004
|
r,
|
|
@@ -1005,23 +1007,23 @@ async function jt(e, t, a, r, o) {
|
|
|
1005
1007
|
o
|
|
1006
1008
|
), j = await ge(
|
|
1007
1009
|
e,
|
|
1008
|
-
{ ...t, chatId: (L =
|
|
1010
|
+
{ ...t, chatId: (L = x.chat) == null ? void 0 : L.id },
|
|
1009
1011
|
r
|
|
1010
1012
|
);
|
|
1011
|
-
return { chatResult:
|
|
1013
|
+
return { chatResult: x, streamingManager: j };
|
|
1012
1014
|
} else {
|
|
1013
|
-
const
|
|
1015
|
+
const x = se(
|
|
1014
1016
|
e,
|
|
1015
1017
|
a,
|
|
1016
1018
|
r,
|
|
1017
1019
|
t.mode,
|
|
1018
1020
|
t.persistentChat,
|
|
1019
1021
|
o
|
|
1020
|
-
), j = ge(e, t, r), [
|
|
1021
|
-
return { chatResult:
|
|
1022
|
+
), j = ge(e, t, r), [B, D] = await Promise.all([x, j]);
|
|
1023
|
+
return { chatResult: B, streamingManager: D };
|
|
1022
1024
|
}
|
|
1023
1025
|
}, { chatResult: c, streamingManager: n } = await i(), { chat: s, chatMode: d } = c;
|
|
1024
|
-
return d && d !== t.mode && (t.mode = d, (h = (l = t.callbacks).onModeChange) == null || h.call(l, d), d !== _.Functional) ? ((b = (
|
|
1026
|
+
return d && d !== t.mode && (t.mode = d, (h = (l = t.callbacks).onModeChange) == null || h.call(l, d), d !== _.Functional) ? ((b = (y = t.callbacks).onError) == null || b.call(y, new Ee(d)), n == null || n.disconnect(), { chat: s }) : { chat: s, streamingManager: n };
|
|
1025
1027
|
}
|
|
1026
1028
|
async function Lt(e, t) {
|
|
1027
1029
|
var D, K, G;
|
|
@@ -1039,7 +1041,7 @@ async function Lt(e, t) {
|
|
|
1039
1041
|
s.track("agent-sdk", { event: "init" });
|
|
1040
1042
|
const d = He(t.auth, c, t.callbacks.onError, t.externalId), l = await d.getById(e), h = le(l.presenter.type);
|
|
1041
1043
|
s.enrich(qe(l));
|
|
1042
|
-
const { onMessage:
|
|
1044
|
+
const { onMessage: y, clearQueue: b } = st(
|
|
1043
1045
|
s,
|
|
1044
1046
|
n,
|
|
1045
1047
|
t,
|
|
@@ -1054,25 +1056,28 @@ async function Lt(e, t) {
|
|
|
1054
1056
|
r = u;
|
|
1055
1057
|
};
|
|
1056
1058
|
s.track("agent-sdk", { event: "loaded", ...Ve(l) });
|
|
1057
|
-
async function
|
|
1058
|
-
var S,
|
|
1059
|
-
(
|
|
1060
|
-
const
|
|
1059
|
+
async function x(u) {
|
|
1060
|
+
var S, $, z, C, E, J, R;
|
|
1061
|
+
($ = (S = t.callbacks).onConnectionStateChange) == null || $.call(S, I.Connecting), N.reset(), u && !a && (delete n.chat, (C = (z = t.callbacks).onNewMessage) == null || C.call(z, [...n.messages], "answer"));
|
|
1062
|
+
const k = t.mode === _.DirectPlayback || h ? Promise.resolve(void 0) : nt(
|
|
1061
1063
|
t.auth,
|
|
1062
1064
|
i,
|
|
1063
|
-
{ onMessage:
|
|
1065
|
+
{ onMessage: y, onError: t.callbacks.onError },
|
|
1064
1066
|
t.externalId
|
|
1065
1067
|
), v = ne(
|
|
1066
1068
|
() => jt(
|
|
1067
1069
|
l,
|
|
1068
|
-
{
|
|
1070
|
+
{
|
|
1071
|
+
...t,
|
|
1072
|
+
callbacks: { ...t.callbacks, onVideoIdChange: L, onMessage: y }
|
|
1073
|
+
},
|
|
1069
1074
|
d,
|
|
1070
1075
|
s,
|
|
1071
1076
|
n.chat
|
|
1072
1077
|
),
|
|
1073
1078
|
{
|
|
1074
1079
|
limit: 3,
|
|
1075
|
-
timeout:
|
|
1080
|
+
timeout: $e,
|
|
1076
1081
|
timeoutErrorMessage: "Timeout initializing the stream",
|
|
1077
1082
|
// Retry on all errors except for connection errors and rate limit errors, these are already handled in client level.
|
|
1078
1083
|
shouldRetryFn: (M) => (M == null ? void 0 : M.message) !== "Could not connect" && M.status !== 429,
|
|
@@ -1080,21 +1085,21 @@ async function Lt(e, t) {
|
|
|
1080
1085
|
}
|
|
1081
1086
|
).catch((M) => {
|
|
1082
1087
|
var U, F;
|
|
1083
|
-
throw
|
|
1084
|
-
}), [T, { streamingManager: g, chat: p }] = await Promise.all([
|
|
1085
|
-
p && p.id !== ((E = n.chat) == null ? void 0 : E.id) && ((
|
|
1088
|
+
throw B(_.Maintenance), (F = (U = t.callbacks).onConnectionStateChange) == null || F.call(U, I.Fail), M;
|
|
1089
|
+
}), [T, { streamingManager: g, chat: p }] = await Promise.all([k, v]);
|
|
1090
|
+
p && p.id !== ((E = n.chat) == null ? void 0 : E.id) && ((R = (J = t.callbacks).onNewChat) == null || R.call(J, p.id)), n.streamingManager = g, n.socketManager = T, n.chat = p, a = !1, s.enrich({
|
|
1086
1091
|
chatId: p == null ? void 0 : p.id,
|
|
1087
1092
|
streamId: g == null ? void 0 : g.streamId,
|
|
1088
1093
|
mode: n.chatMode
|
|
1089
|
-
}),
|
|
1094
|
+
}), B((p == null ? void 0 : p.chat_mode) ?? t.mode ?? _.Functional);
|
|
1090
1095
|
}
|
|
1091
1096
|
async function j() {
|
|
1092
|
-
var u,
|
|
1093
|
-
(u = n.socketManager) == null || u.disconnect(), await ((
|
|
1097
|
+
var u, k, v, T;
|
|
1098
|
+
(u = n.socketManager) == null || u.disconnect(), await ((k = n.streamingManager) == null ? void 0 : k.disconnect()), delete n.streamingManager, delete n.socketManager, (T = (v = t.callbacks).onConnectionStateChange) == null || T.call(v, I.Disconnected);
|
|
1094
1099
|
}
|
|
1095
|
-
async function
|
|
1096
|
-
var
|
|
1097
|
-
u !== n.chatMode && (s.track("agent-mode-change", { mode: u }), n.chatMode = u, n.chatMode !== _.Functional && await j(), (v = (
|
|
1100
|
+
async function B(u) {
|
|
1101
|
+
var k, v;
|
|
1102
|
+
u !== n.chatMode && (s.track("agent-mode-change", { mode: u }), n.chatMode = u, n.chatMode !== _.Functional && await j(), (v = (k = t.callbacks).onModeChange) == null || v.call(k, u));
|
|
1098
1103
|
}
|
|
1099
1104
|
return {
|
|
1100
1105
|
agent: l,
|
|
@@ -1112,16 +1117,16 @@ async function Lt(e, t) {
|
|
|
1112
1117
|
},
|
|
1113
1118
|
starterMessages: ((G = l.knowledge) == null ? void 0 : G.starter_message) || [],
|
|
1114
1119
|
getSTTToken: () => d.getSTTToken(l.id),
|
|
1115
|
-
changeMode:
|
|
1120
|
+
changeMode: B,
|
|
1116
1121
|
enrichAnalytics: s.enrich,
|
|
1117
1122
|
async connect() {
|
|
1118
|
-
await
|
|
1123
|
+
await x(!0), s.track("agent-chat", {
|
|
1119
1124
|
event: "connect",
|
|
1120
1125
|
mode: n.chatMode
|
|
1121
1126
|
});
|
|
1122
1127
|
},
|
|
1123
1128
|
async reconnect() {
|
|
1124
|
-
await j(), await
|
|
1129
|
+
await j(), await x(!1), s.track("agent-chat", {
|
|
1125
1130
|
event: "reconnect",
|
|
1126
1131
|
mode: n.chatMode
|
|
1127
1132
|
});
|
|
@@ -1133,8 +1138,8 @@ async function Lt(e, t) {
|
|
|
1133
1138
|
});
|
|
1134
1139
|
},
|
|
1135
1140
|
async chat(u) {
|
|
1136
|
-
var g, p, S,
|
|
1137
|
-
const
|
|
1141
|
+
var g, p, S, $, z;
|
|
1142
|
+
const k = () => {
|
|
1138
1143
|
if (ve(t.mode))
|
|
1139
1144
|
throw new H(`${t.mode} is enabled, chat is disabled`);
|
|
1140
1145
|
if (u.length >= 800)
|
|
@@ -1165,18 +1170,16 @@ async function Lt(e, t) {
|
|
|
1165
1170
|
}
|
|
1166
1171
|
return n.chat.id;
|
|
1167
1172
|
}, T = async (C, E) => ne(h ? async () => {
|
|
1168
|
-
var
|
|
1169
|
-
return await ((M = (
|
|
1170
|
-
result: "This is a mock message until the data channel is implemented."
|
|
1171
|
-
});
|
|
1173
|
+
var R, M;
|
|
1174
|
+
return await ((M = (R = n.streamingManager) == null ? void 0 : R.sendTextMessage) == null ? void 0 : M.call(R, u)), Promise.resolve({});
|
|
1172
1175
|
} : async () => {
|
|
1173
|
-
var
|
|
1176
|
+
var R, M;
|
|
1174
1177
|
return d.chat(
|
|
1175
1178
|
l.id,
|
|
1176
1179
|
E,
|
|
1177
1180
|
{
|
|
1178
1181
|
chatMode: n.chatMode,
|
|
1179
|
-
streamId: (
|
|
1182
|
+
streamId: (R = n.streamingManager) == null ? void 0 : R.streamId,
|
|
1180
1183
|
sessionId: (M = n.streamingManager) == null ? void 0 : M.sessionId,
|
|
1181
1184
|
messages: C.map(({ matches: U, ...F }) => F)
|
|
1182
1185
|
},
|
|
@@ -1187,17 +1190,17 @@ async function Lt(e, t) {
|
|
|
1187
1190
|
);
|
|
1188
1191
|
}, {
|
|
1189
1192
|
limit: 2,
|
|
1190
|
-
shouldRetryFn: (
|
|
1193
|
+
shouldRetryFn: (R) => {
|
|
1191
1194
|
var F, X, f, m;
|
|
1192
|
-
const M = (F =
|
|
1193
|
-
return !((X =
|
|
1195
|
+
const M = (F = R == null ? void 0 : R.message) == null ? void 0 : F.includes("missing or invalid session_id");
|
|
1196
|
+
return !((X = R == null ? void 0 : R.message) == null ? void 0 : X.includes("Stream Error")) && !M ? ((m = (f = t.callbacks).onError) == null || m.call(f, R), !1) : !0;
|
|
1194
1197
|
},
|
|
1195
1198
|
onRetry: async () => {
|
|
1196
|
-
await j(), await
|
|
1199
|
+
await j(), await x(!1);
|
|
1197
1200
|
}
|
|
1198
1201
|
});
|
|
1199
1202
|
try {
|
|
1200
|
-
b(),
|
|
1203
|
+
b(), k(), n.messages.push({
|
|
1201
1204
|
id: q(),
|
|
1202
1205
|
role: "user",
|
|
1203
1206
|
content: u,
|
|
@@ -1214,7 +1217,7 @@ async function Lt(e, t) {
|
|
|
1214
1217
|
}), s.track("agent-message-send", {
|
|
1215
1218
|
event: "success",
|
|
1216
1219
|
messages: n.messages.length + 1
|
|
1217
|
-
}), E.result && ((
|
|
1220
|
+
}), E.result && (($ = (S = t.callbacks).onNewMessage) == null || $.call(S, [...n.messages], "answer"), s.track("agent-message-received", {
|
|
1218
1221
|
latency: N.get(!0),
|
|
1219
1222
|
messages: n.messages.length
|
|
1220
1223
|
})), E;
|
|
@@ -1225,8 +1228,8 @@ async function Lt(e, t) {
|
|
|
1225
1228
|
}), C;
|
|
1226
1229
|
}
|
|
1227
1230
|
},
|
|
1228
|
-
rate(u,
|
|
1229
|
-
var p, S,
|
|
1231
|
+
rate(u, k, v) {
|
|
1232
|
+
var p, S, $, z;
|
|
1230
1233
|
const T = n.messages.find((C) => C.id === u);
|
|
1231
1234
|
if (n.chat) {
|
|
1232
1235
|
if (!T)
|
|
@@ -1235,20 +1238,20 @@ async function Lt(e, t) {
|
|
|
1235
1238
|
const g = ((p = T.matches) == null ? void 0 : p.map((C) => [C.document_id, C.id])) ?? [];
|
|
1236
1239
|
return s.track("agent-rate", {
|
|
1237
1240
|
event: v ? "update" : "create",
|
|
1238
|
-
thumb:
|
|
1241
|
+
thumb: k === 1 ? "up" : "down",
|
|
1239
1242
|
knowledge_id: ((S = l.knowledge) == null ? void 0 : S.id) ?? "",
|
|
1240
1243
|
matches: g,
|
|
1241
|
-
score:
|
|
1244
|
+
score: k
|
|
1242
1245
|
}), v ? d.updateRating(l.id, n.chat.id, v, {
|
|
1243
|
-
knowledge_id: ((
|
|
1246
|
+
knowledge_id: (($ = l.knowledge) == null ? void 0 : $.id) ?? "",
|
|
1244
1247
|
message_id: u,
|
|
1245
1248
|
matches: g,
|
|
1246
|
-
score:
|
|
1249
|
+
score: k
|
|
1247
1250
|
}) : d.createRating(l.id, n.chat.id, {
|
|
1248
1251
|
knowledge_id: ((z = l.knowledge) == null ? void 0 : z.id) ?? "",
|
|
1249
1252
|
message_id: u,
|
|
1250
1253
|
matches: g,
|
|
1251
|
-
score:
|
|
1254
|
+
score: k
|
|
1252
1255
|
});
|
|
1253
1256
|
},
|
|
1254
1257
|
deleteRate(u) {
|
|
@@ -1258,7 +1261,7 @@ async function Lt(e, t) {
|
|
|
1258
1261
|
},
|
|
1259
1262
|
async speak(u) {
|
|
1260
1263
|
var g, p, S;
|
|
1261
|
-
function
|
|
1264
|
+
function k() {
|
|
1262
1265
|
if (typeof u == "string") {
|
|
1263
1266
|
if (!l.presenter.voice)
|
|
1264
1267
|
throw new Error("Presenter voice is not initialized");
|
|
@@ -1281,7 +1284,7 @@ async function Lt(e, t) {
|
|
|
1281
1284
|
}
|
|
1282
1285
|
return u;
|
|
1283
1286
|
}
|
|
1284
|
-
const v =
|
|
1287
|
+
const v = k();
|
|
1285
1288
|
if (s.track("agent-speak", v), N.update(), n.messages && v.type === "text" && (n.messages.push({
|
|
1286
1289
|
id: q(),
|
|
1287
1290
|
role: "assistant",
|
|
@@ -1303,12 +1306,12 @@ async function Lt(e, t) {
|
|
|
1303
1306
|
async interrupt({ type: u }) {
|
|
1304
1307
|
var v, T, g;
|
|
1305
1308
|
Ge(n.streamingManager, (v = n.streamingManager) == null ? void 0 : v.streamType, r);
|
|
1306
|
-
const
|
|
1309
|
+
const k = n.messages[n.messages.length - 1];
|
|
1307
1310
|
s.track("agent-video-interrupt", {
|
|
1308
1311
|
type: u || "click",
|
|
1309
1312
|
video_duration_to_interrupt: ie.get(!0),
|
|
1310
1313
|
message_duration_to_interrupt: N.get(!0)
|
|
1311
|
-
}),
|
|
1314
|
+
}), k.interrupted = !0, (g = (T = t.callbacks).onNewMessage) == null || g.call(T, [...n.messages], "answer"), et(n.streamingManager, r);
|
|
1312
1315
|
}
|
|
1313
1316
|
};
|
|
1314
1317
|
}
|
|
@@ -1330,15 +1333,15 @@ export {
|
|
|
1330
1333
|
te as d,
|
|
1331
1334
|
w as e,
|
|
1332
1335
|
P as f,
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1336
|
+
V as g,
|
|
1337
|
+
Ie as h,
|
|
1338
|
+
Ee as i,
|
|
1339
|
+
Lt as j,
|
|
1340
|
+
Ae as k,
|
|
1341
|
+
_ as l,
|
|
1339
1342
|
Pe as m,
|
|
1340
1343
|
he as n,
|
|
1341
1344
|
bt as o,
|
|
1342
|
-
|
|
1343
|
-
|
|
1345
|
+
xe as p,
|
|
1346
|
+
Be as q
|
|
1344
1347
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as t,
|
|
1
|
+
import { A as t, k as s, h as r, l as o, i as n, g as i, C as d, b as S, D as p, K as c, P as g, p as C, R as m, f as y, S as T, e as l, m as A, T as P, U as h, V as v, n as V, q as u, W as D, j as E, o as M } from "./index-DKb-cXkg.js";
|
|
2
2
|
export {
|
|
3
3
|
t as AgentActivityState,
|
|
4
4
|
s as AgentStatus,
|