@d-id/client-sdk 1.1.17-staging.75 → 1.1.17-staging.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
var De = Object.defineProperty;
|
|
2
2
|
var Se = (e, t, a) => t in e ? De(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
|
|
3
|
-
var
|
|
3
|
+
var Q = (e, t, a) => Se(e, typeof t != "symbol" ? t + "" : t, a);
|
|
4
4
|
class ee extends Error {
|
|
5
5
|
constructor({ kind: a, description: r, error: o }) {
|
|
6
6
|
super(JSON.stringify({ kind: a, description: r }));
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
Q(this, "kind");
|
|
8
|
+
Q(this, "description");
|
|
9
|
+
Q(this, "error");
|
|
10
10
|
this.kind = a, this.description = r, this.error = o;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -23,10 +23,10 @@ class Ee extends ee {
|
|
|
23
23
|
super({ kind: "ChatModeDowngraded", description: `Chat mode downgraded to ${t}` });
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
class
|
|
26
|
+
class H extends ee {
|
|
27
27
|
constructor(a, r) {
|
|
28
28
|
super({ kind: "ValidationError", description: a });
|
|
29
|
-
|
|
29
|
+
Q(this, "key");
|
|
30
30
|
this.key = r;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -35,8 +35,8 @@ class Me extends ee {
|
|
|
35
35
|
super({ kind: "WSError", description: t });
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
var _e = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(_e || {}), Te = /* @__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))(Te || {}), Ae = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(Ae || {}), je = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(je || {}), _ = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e.Off = "Off", e))(_ || {}),
|
|
39
|
-
const
|
|
38
|
+
var _e = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(_e || {}), Te = /* @__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))(Te || {}), Ae = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(Ae || {}), je = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(je || {}), _ = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e.Off = "Off", e))(_ || {}), V = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Complete = "done", e))(V || {}), Pe = /* @__PURE__ */ ((e) => (e.KnowledgeProcessing = "knowledge/processing", e.KnowledgeIndexing = "knowledge/indexing", e.KnowledgeFailed = "knowledge/error", e.KnowledgeDone = "knowledge/done", e))(Pe || {}), be = /* @__PURE__ */ ((e) => (e.Knowledge = "knowledge", e.Document = "document", e.Record = "record", e))(be || {}), Le = /* @__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))(Le || {}), he = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e.Expressive = "expressive", e))(he || {});
|
|
39
|
+
const bt = (e) => {
|
|
40
40
|
switch (e) {
|
|
41
41
|
case "clip":
|
|
42
42
|
return "clip";
|
|
@@ -46,8 +46,8 @@ const Pt = (e) => {
|
|
|
46
46
|
throw new Error(`Unknown video type: ${e}`);
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
var w = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(w || {}),
|
|
50
|
-
const xe = 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)),
|
|
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 || {}), Be = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.AzureOpenAi = "azure-openai", e.Microsoft = "microsoft", e.Afflorithmics = "afflorithmics", e.Elevenlabs = "elevenlabs", e))(Be || {}), $e = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e))($e || {});
|
|
50
|
+
const xe = 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
51
|
const t = new Uint8Array(e);
|
|
52
52
|
return window.crypto.getRandomValues(t), Array.from(t, (a) => a.toString(16).padStart(2, "0")).join("").slice(0, 13);
|
|
53
53
|
}, 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);
|
|
@@ -89,12 +89,12 @@ function ae(e) {
|
|
|
89
89
|
return window.localStorage.setItem("did_external_key_id", e), e;
|
|
90
90
|
let t = window.localStorage.getItem("did_external_key_id");
|
|
91
91
|
if (!t) {
|
|
92
|
-
let a =
|
|
92
|
+
let a = q();
|
|
93
93
|
window.localStorage.setItem("did_external_key_id", a), t = a;
|
|
94
94
|
}
|
|
95
95
|
return t;
|
|
96
96
|
}
|
|
97
|
-
let Ue =
|
|
97
|
+
let Ue = q();
|
|
98
98
|
function ye(e, t) {
|
|
99
99
|
if (e.type === "bearer")
|
|
100
100
|
return `Bearer ${e.token}`;
|
|
@@ -248,7 +248,7 @@ function Qe(e) {
|
|
|
248
248
|
...e.mixpanelAdditionalProperties || {}
|
|
249
249
|
},
|
|
250
250
|
isEnabled: e.isEnabled ?? !0,
|
|
251
|
-
getRandom:
|
|
251
|
+
getRandom: q,
|
|
252
252
|
enrich(a) {
|
|
253
253
|
this.additionalProperties = { ...this.additionalProperties, ...a };
|
|
254
254
|
},
|
|
@@ -357,10 +357,10 @@ async function et(e, t) {
|
|
|
357
357
|
function tt(e) {
|
|
358
358
|
return new Promise((t, a) => {
|
|
359
359
|
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(
|
|
360
|
+
h.onmessage = n, h.onclose = d, h.onerror = (R) => {
|
|
361
|
+
console.error(R), l == null || l("Websocket failed to connect", R), a(R);
|
|
362
|
+
}, h.onopen = (R) => {
|
|
363
|
+
s == null || s(R), t(h);
|
|
364
364
|
};
|
|
365
365
|
});
|
|
366
366
|
}
|
|
@@ -409,12 +409,12 @@ function at(e) {
|
|
|
409
409
|
}
|
|
410
410
|
function it(e, t, a, r, o) {
|
|
411
411
|
const i = r.messages[r.messages.length - 1];
|
|
412
|
-
if (!(e ===
|
|
412
|
+
if (!(e === V.Partial || e === V.Answer) || (i == null ? void 0 : i.role) !== "assistant")
|
|
413
413
|
return;
|
|
414
414
|
const { content: c, sequence: n } = t;
|
|
415
|
-
e ===
|
|
415
|
+
e === V.Partial ? a[n] = c : a.answer = c;
|
|
416
416
|
const s = at(a);
|
|
417
|
-
(i.content !== s || e ===
|
|
417
|
+
(i.content !== s || e === V.Answer) && (i.content = s, o == null || o([...r.messages], e));
|
|
418
418
|
}
|
|
419
419
|
function st(e, t, a, r, o) {
|
|
420
420
|
let i = {};
|
|
@@ -423,19 +423,19 @@ function st(e, t, a, r, o) {
|
|
|
423
423
|
onMessage: (c, n) => {
|
|
424
424
|
var s, d;
|
|
425
425
|
if ("content" in n)
|
|
426
|
-
it(c, n, i, t, a.callbacks.onNewMessage), c ===
|
|
426
|
+
it(c, n, i, t, a.callbacks.onNewMessage), c === V.Answer && e.track("agent-message-received", {
|
|
427
427
|
messages: t.messages.length,
|
|
428
428
|
mode: t.chatMode
|
|
429
429
|
});
|
|
430
430
|
else {
|
|
431
|
-
const l = P, h = [l.StreamVideoDone, l.StreamVideoError, l.StreamVideoRejected],
|
|
431
|
+
const l = P, h = [l.StreamVideoDone, l.StreamVideoError, l.StreamVideoRejected], R = [l.StreamFailed, l.StreamVideoError, l.StreamVideoRejected], b = Xe(n, r, { mode: t.chatMode });
|
|
432
432
|
if (c = c, c === l.StreamVideoCreated)
|
|
433
|
-
e.linkTrack("agent-video",
|
|
433
|
+
e.linkTrack("agent-video", b, l.StreamVideoCreated, ["start"]);
|
|
434
434
|
else if (h.includes(c)) {
|
|
435
|
-
const
|
|
436
|
-
|
|
435
|
+
const L = c.split("/")[1];
|
|
436
|
+
R.includes(c) ? e.track("agent-video", { ...b, event: L }) : e.linkTrack("agent-video", { ...b, event: L }, c, ["done"]);
|
|
437
437
|
}
|
|
438
|
-
|
|
438
|
+
R.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
439
|
}
|
|
440
440
|
}
|
|
441
441
|
};
|
|
@@ -503,8 +503,12 @@ function lt(e) {
|
|
|
503
503
|
}
|
|
504
504
|
function ut(e) {
|
|
505
505
|
let t = "", a = 0;
|
|
506
|
-
for (const r of e.values())
|
|
507
|
-
if (r && r.type === "codec" && r.mimeType.startsWith("video") && (t = r.mimeType.split("/")[1]), r && r.type === "candidate-pair"
|
|
506
|
+
for (const r of e.values()) {
|
|
507
|
+
if (r && r.type === "codec" && r.mimeType.startsWith("video") && (t = r.mimeType.split("/")[1]), r && r.type === "candidate-pair") {
|
|
508
|
+
const o = r.currentRoundTripTime, c = r.nominated === !0;
|
|
509
|
+
o > 0 && (c || a === 0) && (a = o);
|
|
510
|
+
}
|
|
511
|
+
if (r && r.type === "inbound-rtp" && r.kind === "video")
|
|
508
512
|
return {
|
|
509
513
|
codec: t,
|
|
510
514
|
rtt: a,
|
|
@@ -524,6 +528,7 @@ function ut(e) {
|
|
|
524
528
|
freezeCount: r.freezeCount,
|
|
525
529
|
freezeDuration: r.totalFreezesDuration
|
|
526
530
|
};
|
|
531
|
+
}
|
|
527
532
|
return {};
|
|
528
533
|
}
|
|
529
534
|
function ft(e, t, a) {
|
|
@@ -612,16 +617,16 @@ function wt() {
|
|
|
612
617
|
return { isReceiving: !1, avgJitterDelayInInterval: r };
|
|
613
618
|
};
|
|
614
619
|
}
|
|
615
|
-
function pt(e, t, a, r, o
|
|
616
|
-
let
|
|
617
|
-
const
|
|
620
|
+
function pt(e, t, a, r, o) {
|
|
621
|
+
let i = [], c, n = 0, s = !1, d = Z.Unknown, l = Z.Unknown, h = 0, R = 0;
|
|
622
|
+
const b = wt();
|
|
618
623
|
return setInterval(async () => {
|
|
619
|
-
const
|
|
620
|
-
if (
|
|
621
|
-
|
|
622
|
-
else if (
|
|
623
|
-
const
|
|
624
|
-
r == null || r(w.Stop,
|
|
624
|
+
const L = await e.getStats(), { isReceiving: B, avgJitterDelayInInterval: j, freezeCount: $ } = b(L), D = ut(L);
|
|
625
|
+
if (B)
|
|
626
|
+
n = 0, h = $ - R, l = j < gt ? Z.Strong : j > ht && h > 1 ? Z.Weak : d, l !== d && (o == null || o(l), d = l, R += h, h = 0), s || (r == null || r(w.Start), c = i[i.length - 1], i = [], s = !0), i.push(D);
|
|
627
|
+
else if (s && (n++, n >= mt)) {
|
|
628
|
+
const K = ft(i, oe, c);
|
|
629
|
+
r == null || r(w.Stop, K), t() || a(), R = $, s = !1;
|
|
625
630
|
}
|
|
626
631
|
}, oe);
|
|
627
632
|
}
|
|
@@ -670,7 +675,7 @@ function Rt({
|
|
|
670
675
|
onAgentActivityStateChange: r,
|
|
671
676
|
report: o
|
|
672
677
|
}) {
|
|
673
|
-
e === w.Start ? a == null || a(w.Start) : e === w.Stop && (a == null || a(w.Stop, o)), t === w.Start ? r == null || r(
|
|
678
|
+
e === w.Start ? a == null || a(w.Start) : e === w.Stop && (a == null || a(w.Stop, o)), t === w.Start ? r == null || r(O.Talking) : t === w.Stop && (r == null || r(O.Idle));
|
|
674
679
|
}
|
|
675
680
|
function me({
|
|
676
681
|
statsSignal: e,
|
|
@@ -689,40 +694,40 @@ function me({
|
|
|
689
694
|
});
|
|
690
695
|
}
|
|
691
696
|
async function Ct(e, t, { debug: a = !1, callbacks: r, auth: o, baseURL: i = te, analytics: c }) {
|
|
692
|
-
var
|
|
697
|
+
var X;
|
|
693
698
|
const n = ct(a, "WebRTCStreamingManager"), s = yt(n);
|
|
694
|
-
let d = !1, l = !1, h = w.Stop,
|
|
695
|
-
const { startConnection:
|
|
699
|
+
let d = !1, l = !1, h = w.Stop, R = w.Stop;
|
|
700
|
+
const { startConnection: b, sendStreamRequest: L, close: B, createStream: j, addIceCandidate: $ } = ot(
|
|
696
701
|
o,
|
|
697
702
|
i,
|
|
698
703
|
e,
|
|
699
704
|
r.onError
|
|
700
705
|
), {
|
|
701
|
-
id:
|
|
706
|
+
id: D,
|
|
702
707
|
offer: K,
|
|
703
|
-
ice_servers:
|
|
708
|
+
ice_servers: G,
|
|
704
709
|
session_id: u,
|
|
705
|
-
fluent:
|
|
710
|
+
fluent: y,
|
|
706
711
|
interrupt_enabled: v,
|
|
707
712
|
triggers_enabled: T
|
|
708
|
-
} = await
|
|
709
|
-
(
|
|
710
|
-
const g = new vt({ iceServers:
|
|
713
|
+
} = await j(t);
|
|
714
|
+
(X = r.onStreamCreated) == null || X.call(r, { stream_id: D, session_id: u, agent_id: e });
|
|
715
|
+
const g = new vt({ iceServers: G }), p = g.createDataChannel("JanusDataChannel");
|
|
711
716
|
if (!u)
|
|
712
717
|
throw new Error("Could not create session_id");
|
|
713
|
-
const S =
|
|
718
|
+
const S = y ? W.Fluent : W.Legacy;
|
|
714
719
|
c.enrich({
|
|
715
720
|
"stream-type": S
|
|
716
721
|
});
|
|
717
|
-
const x = t.stream_warmup && !
|
|
722
|
+
const x = t.stream_warmup && !y, z = () => d, C = () => {
|
|
718
723
|
var f;
|
|
719
724
|
d = !0, l && ((f = r.onConnectionStateChange) == null || f.call(r, I.Connected));
|
|
720
725
|
}, E = pt(
|
|
721
726
|
g,
|
|
722
727
|
z,
|
|
723
|
-
|
|
728
|
+
C,
|
|
724
729
|
(f, m) => me({
|
|
725
|
-
statsSignal:
|
|
730
|
+
statsSignal: R = f,
|
|
726
731
|
dataChannelSignal: S === W.Legacy ? h : void 0,
|
|
727
732
|
onVideoStateChange: r.onVideoStateChange,
|
|
728
733
|
onAgentActivityStateChange: r.onAgentActivityStateChange,
|
|
@@ -732,39 +737,38 @@ async function Ct(e, t, { debug: a = !1, callbacks: r, auth: o, baseURL: i = te,
|
|
|
732
737
|
(f) => {
|
|
733
738
|
var m;
|
|
734
739
|
return (m = r.onConnectivityStateChange) == null ? void 0 : m.call(r, f);
|
|
735
|
-
}
|
|
736
|
-
x
|
|
740
|
+
}
|
|
737
741
|
);
|
|
738
742
|
g.onicecandidate = (f) => {
|
|
739
743
|
var m;
|
|
740
744
|
n("peerConnection.onicecandidate", f);
|
|
741
745
|
try {
|
|
742
746
|
f.candidate && f.candidate.sdpMid && f.candidate.sdpMLineIndex !== null ? $(
|
|
743
|
-
|
|
747
|
+
D,
|
|
744
748
|
{
|
|
745
749
|
candidate: f.candidate.candidate,
|
|
746
750
|
sdpMid: f.candidate.sdpMid,
|
|
747
751
|
sdpMLineIndex: f.candidate.sdpMLineIndex
|
|
748
752
|
},
|
|
749
753
|
u
|
|
750
|
-
) : $(
|
|
751
|
-
} catch (
|
|
752
|
-
(m = r.onError) == null || m.call(r,
|
|
754
|
+
) : $(D, { candidate: null }, u);
|
|
755
|
+
} catch (A) {
|
|
756
|
+
(m = r.onError) == null || m.call(r, A, { streamId: D });
|
|
753
757
|
}
|
|
754
758
|
}, p.onopen = () => {
|
|
755
|
-
l = !0, (!x || d) &&
|
|
759
|
+
l = !0, (!x || d) && C();
|
|
756
760
|
};
|
|
757
761
|
const J = (f) => {
|
|
758
762
|
var m;
|
|
759
763
|
(m = r.onVideoIdChange) == null || m.call(r, f);
|
|
760
764
|
};
|
|
761
|
-
function
|
|
765
|
+
function k(f, m) {
|
|
762
766
|
if (f === P.StreamStarted && typeof m == "object" && "metadata" in m) {
|
|
763
|
-
const
|
|
764
|
-
J(
|
|
767
|
+
const A = m.metadata;
|
|
768
|
+
J(A.videoId);
|
|
765
769
|
}
|
|
766
770
|
f === P.StreamDone && J(null), h = f === P.StreamStarted ? w.Start : w.Stop, me({
|
|
767
|
-
statsSignal: S === W.Legacy ?
|
|
771
|
+
statsSignal: S === W.Legacy ? R : void 0,
|
|
768
772
|
dataChannelSignal: h,
|
|
769
773
|
onVideoStateChange: r.onVideoStateChange,
|
|
770
774
|
onAgentActivityStateChange: r.onAgentActivityStateChange,
|
|
@@ -772,18 +776,18 @@ async function Ct(e, t, { debug: a = !1, callbacks: r, auth: o, baseURL: i = te,
|
|
|
772
776
|
});
|
|
773
777
|
}
|
|
774
778
|
function M(f, m) {
|
|
775
|
-
const
|
|
776
|
-
|
|
779
|
+
const A = typeof m == "string" ? m : m == null ? void 0 : m.metadata;
|
|
780
|
+
A && c.enrich({ streamMetadata: A }), c.track("agent-chat", { event: "ready" });
|
|
777
781
|
}
|
|
778
782
|
const U = {
|
|
779
|
-
[P.StreamStarted]:
|
|
780
|
-
[P.StreamDone]:
|
|
783
|
+
[P.StreamStarted]: k,
|
|
784
|
+
[P.StreamDone]: k,
|
|
781
785
|
[P.StreamReady]: M
|
|
782
786
|
};
|
|
783
787
|
p.onmessage = (f) => {
|
|
784
|
-
var
|
|
785
|
-
const { subject: m, data:
|
|
786
|
-
(
|
|
788
|
+
var Y;
|
|
789
|
+
const { subject: m, data: A } = s(f.data);
|
|
790
|
+
(Y = U[m]) == null || Y.call(U, m, A);
|
|
787
791
|
}, g.oniceconnectionstatechange = () => {
|
|
788
792
|
var m;
|
|
789
793
|
n("peerConnection.oniceconnectionstatechange => " + g.iceConnectionState);
|
|
@@ -794,20 +798,20 @@ async function Ct(e, t, { debug: a = !1, callbacks: r, auth: o, baseURL: i = te,
|
|
|
794
798
|
n("peerConnection.ontrack", f), (m = r.onSrcObjectReady) == null || m.call(r, f.streams[0]);
|
|
795
799
|
}, await g.setRemoteDescription(K), n("set remote description OK");
|
|
796
800
|
const F = await g.createAnswer();
|
|
797
|
-
return n("create answer OK"), await g.setLocalDescription(F), n("set local description OK"), await
|
|
801
|
+
return n("create answer OK"), await g.setLocalDescription(F), n("set local description OK"), await b(D, F, u), n("start connection OK"), {
|
|
798
802
|
/**
|
|
799
803
|
* Method to send request to server to get clip or talk depend on you payload
|
|
800
804
|
* @param payload
|
|
801
805
|
*/
|
|
802
806
|
speak(f) {
|
|
803
|
-
return
|
|
807
|
+
return L(D, u, f);
|
|
804
808
|
},
|
|
805
809
|
/**
|
|
806
810
|
* Method to close RTC connection
|
|
807
811
|
*/
|
|
808
812
|
async disconnect() {
|
|
809
813
|
var f;
|
|
810
|
-
if (
|
|
814
|
+
if (D) {
|
|
811
815
|
const m = fe(g.iceConnectionState);
|
|
812
816
|
if (g) {
|
|
813
817
|
if (m === I.New) {
|
|
@@ -817,29 +821,29 @@ async function Ct(e, t, { debug: a = !1, callbacks: r, auth: o, baseURL: i = te,
|
|
|
817
821
|
g.close(), g.oniceconnectionstatechange = null, g.onnegotiationneeded = null, g.onicecandidate = null, g.ontrack = null;
|
|
818
822
|
}
|
|
819
823
|
try {
|
|
820
|
-
m === I.Connected && await
|
|
824
|
+
m === I.Connected && await B(D, u).catch((A) => {
|
|
821
825
|
});
|
|
822
|
-
} catch (
|
|
823
|
-
n("Error on close stream connection",
|
|
826
|
+
} catch (A) {
|
|
827
|
+
n("Error on close stream connection", A);
|
|
824
828
|
}
|
|
825
|
-
(f = r.onAgentActivityStateChange) == null || f.call(r,
|
|
829
|
+
(f = r.onAgentActivityStateChange) == null || f.call(r, O.Idle), clearInterval(E);
|
|
826
830
|
}
|
|
827
831
|
},
|
|
828
832
|
/**
|
|
829
833
|
* Method to send data channel messages to the server
|
|
830
834
|
*/
|
|
831
835
|
sendDataChannelMessage(f) {
|
|
832
|
-
var m,
|
|
836
|
+
var m, A;
|
|
833
837
|
if (!d || p.readyState !== "open") {
|
|
834
838
|
n("Data channel is not ready for sending messages"), (m = r.onError) == null || m.call(r, new Error("Data channel is not ready for sending messages"), {
|
|
835
|
-
streamId:
|
|
839
|
+
streamId: D
|
|
836
840
|
});
|
|
837
841
|
return;
|
|
838
842
|
}
|
|
839
843
|
try {
|
|
840
844
|
p.send(f);
|
|
841
|
-
} catch (
|
|
842
|
-
n("Error sending data channel message",
|
|
845
|
+
} catch (Y) {
|
|
846
|
+
n("Error sending data channel message", Y), (A = r.onError) == null || A.call(r, Y, { streamId: D });
|
|
843
847
|
}
|
|
844
848
|
},
|
|
845
849
|
/**
|
|
@@ -849,7 +853,7 @@ async function Ct(e, t, { debug: a = !1, callbacks: r, auth: o, baseURL: i = te,
|
|
|
849
853
|
/**
|
|
850
854
|
* Id of current RTC stream
|
|
851
855
|
*/
|
|
852
|
-
streamId:
|
|
856
|
+
streamId: D,
|
|
853
857
|
streamType: S,
|
|
854
858
|
interruptAvailable: v ?? !1,
|
|
855
859
|
triggersAvailable: T ?? !1
|
|
@@ -867,7 +871,7 @@ async function Dt(e, t, a) {
|
|
|
867
871
|
const { version: o, ...i } = t;
|
|
868
872
|
switch (i.transport_provider) {
|
|
869
873
|
case de.Livekit:
|
|
870
|
-
const { createLiveKitStreamingManager: c } = await import("./livekit-manager-
|
|
874
|
+
const { createLiveKitStreamingManager: c } = await import("./livekit-manager-C6I2lSHF.js");
|
|
871
875
|
return c(r, i, a);
|
|
872
876
|
default:
|
|
873
877
|
throw new Error(`Unsupported transport provider: ${i.transport_provider}`);
|
|
@@ -973,8 +977,8 @@ function ge(e, t, a) {
|
|
|
973
977
|
},
|
|
974
978
|
onAgentActivityStateChange: (n) => {
|
|
975
979
|
var s, d;
|
|
976
|
-
(d = (s = t.callbacks).onAgentActivityStateChange) == null || d.call(s, n), n ===
|
|
977
|
-
n ===
|
|
980
|
+
(d = (s = t.callbacks).onAgentActivityStateChange) == null || d.call(s, n), n === O.Talking ? ie.update() : ie.reset(), Tt(
|
|
981
|
+
n === O.Talking ? w.Start : w.Stop,
|
|
978
982
|
e,
|
|
979
983
|
a,
|
|
980
984
|
i.streamType
|
|
@@ -988,39 +992,39 @@ function ge(e, t, a) {
|
|
|
988
992
|
});
|
|
989
993
|
}
|
|
990
994
|
async function jt(e, t, a, r, o) {
|
|
991
|
-
var l, h,
|
|
995
|
+
var l, h, R, b;
|
|
992
996
|
const i = async () => {
|
|
993
|
-
var
|
|
997
|
+
var L;
|
|
994
998
|
if (le(e.presenter.type)) {
|
|
995
|
-
const
|
|
999
|
+
const B = await se(
|
|
996
1000
|
e,
|
|
997
1001
|
a,
|
|
998
1002
|
r,
|
|
999
1003
|
t.mode,
|
|
1000
1004
|
t.persistentChat,
|
|
1001
1005
|
o
|
|
1002
|
-
),
|
|
1006
|
+
), j = await ge(
|
|
1003
1007
|
e,
|
|
1004
|
-
{ ...t, chatId: (
|
|
1008
|
+
{ ...t, chatId: (L = B.chat) == null ? void 0 : L.id },
|
|
1005
1009
|
r
|
|
1006
1010
|
);
|
|
1007
|
-
return { chatResult:
|
|
1011
|
+
return { chatResult: B, streamingManager: j };
|
|
1008
1012
|
} else {
|
|
1009
|
-
const
|
|
1013
|
+
const B = se(
|
|
1010
1014
|
e,
|
|
1011
1015
|
a,
|
|
1012
1016
|
r,
|
|
1013
1017
|
t.mode,
|
|
1014
1018
|
t.persistentChat,
|
|
1015
1019
|
o
|
|
1016
|
-
),
|
|
1017
|
-
return { chatResult: $, streamingManager:
|
|
1020
|
+
), j = ge(e, t, r), [$, D] = await Promise.all([B, j]);
|
|
1021
|
+
return { chatResult: $, streamingManager: D };
|
|
1018
1022
|
}
|
|
1019
1023
|
}, { chatResult: c, streamingManager: n } = await i(), { chat: s, chatMode: d } = c;
|
|
1020
|
-
return d && d !== t.mode && (t.mode = d, (h = (l = t.callbacks).onModeChange) == null || h.call(l, d), d !== _.Functional) ? ((
|
|
1024
|
+
return d && d !== t.mode && (t.mode = d, (h = (l = t.callbacks).onModeChange) == null || h.call(l, d), d !== _.Functional) ? ((b = (R = t.callbacks).onError) == null || b.call(R, new Ee(d)), n == null || n.disconnect(), { chat: s }) : { chat: s, streamingManager: n };
|
|
1021
1025
|
}
|
|
1022
1026
|
async function Lt(e, t) {
|
|
1023
|
-
var
|
|
1027
|
+
var D, K, G;
|
|
1024
1028
|
let a = !0, r = null;
|
|
1025
1029
|
const o = t.mixpanelKey || Ne, i = t.wsURL || Fe, c = t.baseURL || te, n = {
|
|
1026
1030
|
messages: [],
|
|
@@ -1035,7 +1039,7 @@ async function Lt(e, t) {
|
|
|
1035
1039
|
s.track("agent-sdk", { event: "init" });
|
|
1036
1040
|
const d = He(t.auth, c, t.callbacks.onError, t.externalId), l = await d.getById(e), h = le(l.presenter.type);
|
|
1037
1041
|
s.enrich(qe(l));
|
|
1038
|
-
const { onMessage:
|
|
1042
|
+
const { onMessage: R, clearQueue: b } = st(
|
|
1039
1043
|
s,
|
|
1040
1044
|
n,
|
|
1041
1045
|
t,
|
|
@@ -1045,23 +1049,23 @@ async function Lt(e, t) {
|
|
|
1045
1049
|
return (u = n.socketManager) == null ? void 0 : u.disconnect();
|
|
1046
1050
|
}
|
|
1047
1051
|
);
|
|
1048
|
-
n.messages = Ze(t.initialMessages), (K = (
|
|
1049
|
-
const
|
|
1052
|
+
n.messages = Ze(t.initialMessages), (K = (D = t.callbacks).onNewMessage) == null || K.call(D, [...n.messages], "answer");
|
|
1053
|
+
const L = (u) => {
|
|
1050
1054
|
r = u;
|
|
1051
1055
|
};
|
|
1052
1056
|
s.track("agent-sdk", { event: "loaded", ...Ve(l) });
|
|
1053
|
-
async function
|
|
1054
|
-
var S, x, z,
|
|
1055
|
-
(x = (S = t.callbacks).onConnectionStateChange) == null || x.call(S, I.Connecting), N.reset(), u && !a && (delete n.chat, (
|
|
1056
|
-
const
|
|
1057
|
+
async function B(u) {
|
|
1058
|
+
var S, x, z, C, E, J, k;
|
|
1059
|
+
(x = (S = t.callbacks).onConnectionStateChange) == null || x.call(S, I.Connecting), N.reset(), u && !a && (delete n.chat, (C = (z = t.callbacks).onNewMessage) == null || C.call(z, [...n.messages], "answer"));
|
|
1060
|
+
const y = t.mode === _.DirectPlayback || h ? Promise.resolve(void 0) : nt(
|
|
1057
1061
|
t.auth,
|
|
1058
1062
|
i,
|
|
1059
|
-
{ onMessage:
|
|
1063
|
+
{ onMessage: R, onError: t.callbacks.onError },
|
|
1060
1064
|
t.externalId
|
|
1061
1065
|
), v = ne(
|
|
1062
1066
|
() => jt(
|
|
1063
1067
|
l,
|
|
1064
|
-
{ ...t, callbacks: { ...t.callbacks, onVideoIdChange:
|
|
1068
|
+
{ ...t, callbacks: { ...t.callbacks, onVideoIdChange: L } },
|
|
1065
1069
|
d,
|
|
1066
1070
|
s,
|
|
1067
1071
|
n.chat
|
|
@@ -1077,20 +1081,20 @@ async function Lt(e, t) {
|
|
|
1077
1081
|
).catch((M) => {
|
|
1078
1082
|
var U, F;
|
|
1079
1083
|
throw $(_.Maintenance), (F = (U = t.callbacks).onConnectionStateChange) == null || F.call(U, I.Fail), M;
|
|
1080
|
-
}), [T, { streamingManager: g, chat: p }] = await Promise.all([
|
|
1081
|
-
p && p.id !== ((E = n.chat) == null ? void 0 : E.id) && ((
|
|
1084
|
+
}), [T, { streamingManager: g, chat: p }] = await Promise.all([y, v]);
|
|
1085
|
+
p && p.id !== ((E = n.chat) == null ? void 0 : E.id) && ((k = (J = t.callbacks).onNewChat) == null || k.call(J, p.id)), n.streamingManager = g, n.socketManager = T, n.chat = p, a = !1, s.enrich({
|
|
1082
1086
|
chatId: p == null ? void 0 : p.id,
|
|
1083
1087
|
streamId: g == null ? void 0 : g.streamId,
|
|
1084
1088
|
mode: n.chatMode
|
|
1085
1089
|
}), $((p == null ? void 0 : p.chat_mode) ?? t.mode ?? _.Functional);
|
|
1086
1090
|
}
|
|
1087
|
-
async function
|
|
1088
|
-
var u,
|
|
1089
|
-
(u = n.socketManager) == null || u.disconnect(), await ((
|
|
1091
|
+
async function j() {
|
|
1092
|
+
var u, y, v, T;
|
|
1093
|
+
(u = n.socketManager) == null || u.disconnect(), await ((y = n.streamingManager) == null ? void 0 : y.disconnect()), delete n.streamingManager, delete n.socketManager, (T = (v = t.callbacks).onConnectionStateChange) == null || T.call(v, I.Disconnected);
|
|
1090
1094
|
}
|
|
1091
1095
|
async function $(u) {
|
|
1092
|
-
var
|
|
1093
|
-
u !== n.chatMode && (s.track("agent-mode-change", { mode: u }), n.chatMode = u, n.chatMode !== _.Functional && await
|
|
1096
|
+
var y, v;
|
|
1097
|
+
u !== n.chatMode && (s.track("agent-mode-change", { mode: u }), n.chatMode = u, n.chatMode !== _.Functional && await j(), (v = (y = t.callbacks).onModeChange) == null || v.call(y, u));
|
|
1094
1098
|
}
|
|
1095
1099
|
return {
|
|
1096
1100
|
agent: l,
|
|
@@ -1106,47 +1110,47 @@ async function Lt(e, t) {
|
|
|
1106
1110
|
var u;
|
|
1107
1111
|
return ((u = n.streamingManager) == null ? void 0 : u.triggersAvailable) ?? !1;
|
|
1108
1112
|
},
|
|
1109
|
-
starterMessages: ((
|
|
1113
|
+
starterMessages: ((G = l.knowledge) == null ? void 0 : G.starter_message) || [],
|
|
1110
1114
|
getSTTToken: () => d.getSTTToken(l.id),
|
|
1111
1115
|
changeMode: $,
|
|
1112
1116
|
enrichAnalytics: s.enrich,
|
|
1113
1117
|
async connect() {
|
|
1114
|
-
await
|
|
1118
|
+
await B(!0), s.track("agent-chat", {
|
|
1115
1119
|
event: "connect",
|
|
1116
1120
|
mode: n.chatMode
|
|
1117
1121
|
});
|
|
1118
1122
|
},
|
|
1119
1123
|
async reconnect() {
|
|
1120
|
-
await
|
|
1124
|
+
await j(), await B(!1), s.track("agent-chat", {
|
|
1121
1125
|
event: "reconnect",
|
|
1122
1126
|
mode: n.chatMode
|
|
1123
1127
|
});
|
|
1124
1128
|
},
|
|
1125
1129
|
async disconnect() {
|
|
1126
|
-
await
|
|
1130
|
+
await j(), s.track("agent-chat", {
|
|
1127
1131
|
event: "disconnect",
|
|
1128
1132
|
mode: n.chatMode
|
|
1129
1133
|
});
|
|
1130
1134
|
},
|
|
1131
1135
|
async chat(u) {
|
|
1132
1136
|
var g, p, S, x, z;
|
|
1133
|
-
const
|
|
1137
|
+
const y = () => {
|
|
1134
1138
|
if (ve(t.mode))
|
|
1135
|
-
throw new
|
|
1139
|
+
throw new H(`${t.mode} is enabled, chat is disabled`);
|
|
1136
1140
|
if (u.length >= 800)
|
|
1137
|
-
throw new
|
|
1141
|
+
throw new H("Message cannot be more than 800 characters");
|
|
1138
1142
|
if (u.length === 0)
|
|
1139
|
-
throw new
|
|
1143
|
+
throw new H("Message cannot be empty");
|
|
1140
1144
|
if (n.chatMode === _.Maintenance)
|
|
1141
|
-
throw new
|
|
1145
|
+
throw new H("Chat is in maintenance mode");
|
|
1142
1146
|
if (![_.TextOnly, _.Playground].includes(n.chatMode)) {
|
|
1143
1147
|
if (!n.streamingManager)
|
|
1144
|
-
throw new
|
|
1148
|
+
throw new H("Streaming manager is not initialized");
|
|
1145
1149
|
if (!n.chat)
|
|
1146
|
-
throw new
|
|
1150
|
+
throw new H("Chat is not initialized");
|
|
1147
1151
|
}
|
|
1148
1152
|
}, v = async () => {
|
|
1149
|
-
var
|
|
1153
|
+
var C, E;
|
|
1150
1154
|
if (!n.chat) {
|
|
1151
1155
|
const J = await se(
|
|
1152
1156
|
l,
|
|
@@ -1157,24 +1161,24 @@ async function Lt(e, t) {
|
|
|
1157
1161
|
);
|
|
1158
1162
|
if (!J.chat)
|
|
1159
1163
|
throw new Ie(n.chatMode, !!t.persistentChat);
|
|
1160
|
-
n.chat = J.chat, (E = (
|
|
1164
|
+
n.chat = J.chat, (E = (C = t.callbacks).onNewChat) == null || E.call(C, n.chat.id);
|
|
1161
1165
|
}
|
|
1162
1166
|
return n.chat.id;
|
|
1163
|
-
}, T = async (
|
|
1164
|
-
var
|
|
1165
|
-
return await ((M = (
|
|
1167
|
+
}, T = async (C, E) => ne(h ? async () => {
|
|
1168
|
+
var k, M;
|
|
1169
|
+
return await ((M = (k = n.streamingManager) == null ? void 0 : k.sendTextMessage) == null ? void 0 : M.call(k, u)), Promise.resolve({
|
|
1166
1170
|
result: "This is a mock message until the data channel is implemented."
|
|
1167
1171
|
});
|
|
1168
1172
|
} : async () => {
|
|
1169
|
-
var
|
|
1173
|
+
var k, M;
|
|
1170
1174
|
return d.chat(
|
|
1171
1175
|
l.id,
|
|
1172
1176
|
E,
|
|
1173
1177
|
{
|
|
1174
1178
|
chatMode: n.chatMode,
|
|
1175
|
-
streamId: (
|
|
1179
|
+
streamId: (k = n.streamingManager) == null ? void 0 : k.streamId,
|
|
1176
1180
|
sessionId: (M = n.streamingManager) == null ? void 0 : M.sessionId,
|
|
1177
|
-
messages:
|
|
1181
|
+
messages: C.map(({ matches: U, ...F }) => F)
|
|
1178
1182
|
},
|
|
1179
1183
|
{
|
|
1180
1184
|
...Ce(n.chatMode),
|
|
@@ -1183,25 +1187,25 @@ async function Lt(e, t) {
|
|
|
1183
1187
|
);
|
|
1184
1188
|
}, {
|
|
1185
1189
|
limit: 2,
|
|
1186
|
-
shouldRetryFn: (
|
|
1187
|
-
var F,
|
|
1188
|
-
const M = (F =
|
|
1189
|
-
return !((
|
|
1190
|
+
shouldRetryFn: (k) => {
|
|
1191
|
+
var F, X, f, m;
|
|
1192
|
+
const M = (F = k == null ? void 0 : k.message) == null ? void 0 : F.includes("missing or invalid session_id");
|
|
1193
|
+
return !((X = k == null ? void 0 : k.message) == null ? void 0 : X.includes("Stream Error")) && !M ? ((m = (f = t.callbacks).onError) == null || m.call(f, k), !1) : !0;
|
|
1190
1194
|
},
|
|
1191
1195
|
onRetry: async () => {
|
|
1192
|
-
await
|
|
1196
|
+
await j(), await B(!1);
|
|
1193
1197
|
}
|
|
1194
1198
|
});
|
|
1195
1199
|
try {
|
|
1196
|
-
|
|
1197
|
-
id:
|
|
1200
|
+
b(), y(), n.messages.push({
|
|
1201
|
+
id: q(),
|
|
1198
1202
|
role: "user",
|
|
1199
1203
|
content: u,
|
|
1200
1204
|
created_at: new Date(N.update()).toISOString()
|
|
1201
1205
|
}), (p = (g = t.callbacks).onNewMessage) == null || p.call(g, [...n.messages], "user");
|
|
1202
|
-
const
|
|
1206
|
+
const C = await v(), E = await T([...n.messages], C);
|
|
1203
1207
|
return n.messages.push({
|
|
1204
|
-
id:
|
|
1208
|
+
id: q(),
|
|
1205
1209
|
role: "assistant",
|
|
1206
1210
|
content: E.result || "",
|
|
1207
1211
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -1214,37 +1218,37 @@ async function Lt(e, t) {
|
|
|
1214
1218
|
latency: N.get(!0),
|
|
1215
1219
|
messages: n.messages.length
|
|
1216
1220
|
})), E;
|
|
1217
|
-
} catch (
|
|
1221
|
+
} catch (C) {
|
|
1218
1222
|
throw ((z = n.messages[n.messages.length - 1]) == null ? void 0 : z.role) === "assistant" && n.messages.pop(), s.track("agent-message-send", {
|
|
1219
1223
|
event: "error",
|
|
1220
1224
|
messages: n.messages.length
|
|
1221
|
-
}),
|
|
1225
|
+
}), C;
|
|
1222
1226
|
}
|
|
1223
1227
|
},
|
|
1224
|
-
rate(u,
|
|
1228
|
+
rate(u, y, v) {
|
|
1225
1229
|
var p, S, x, z;
|
|
1226
|
-
const T = n.messages.find((
|
|
1230
|
+
const T = n.messages.find((C) => C.id === u);
|
|
1227
1231
|
if (n.chat) {
|
|
1228
1232
|
if (!T)
|
|
1229
1233
|
throw new Error("Message not found");
|
|
1230
1234
|
} else throw new Error("Chat is not initialized");
|
|
1231
|
-
const g = ((p = T.matches) == null ? void 0 : p.map((
|
|
1235
|
+
const g = ((p = T.matches) == null ? void 0 : p.map((C) => [C.document_id, C.id])) ?? [];
|
|
1232
1236
|
return s.track("agent-rate", {
|
|
1233
1237
|
event: v ? "update" : "create",
|
|
1234
|
-
thumb:
|
|
1238
|
+
thumb: y === 1 ? "up" : "down",
|
|
1235
1239
|
knowledge_id: ((S = l.knowledge) == null ? void 0 : S.id) ?? "",
|
|
1236
1240
|
matches: g,
|
|
1237
|
-
score:
|
|
1241
|
+
score: y
|
|
1238
1242
|
}), v ? d.updateRating(l.id, n.chat.id, v, {
|
|
1239
1243
|
knowledge_id: ((x = l.knowledge) == null ? void 0 : x.id) ?? "",
|
|
1240
1244
|
message_id: u,
|
|
1241
1245
|
matches: g,
|
|
1242
|
-
score:
|
|
1246
|
+
score: y
|
|
1243
1247
|
}) : d.createRating(l.id, n.chat.id, {
|
|
1244
1248
|
knowledge_id: ((z = l.knowledge) == null ? void 0 : z.id) ?? "",
|
|
1245
1249
|
message_id: u,
|
|
1246
1250
|
matches: g,
|
|
1247
|
-
score:
|
|
1251
|
+
score: y
|
|
1248
1252
|
});
|
|
1249
1253
|
},
|
|
1250
1254
|
deleteRate(u) {
|
|
@@ -1254,7 +1258,7 @@ async function Lt(e, t) {
|
|
|
1254
1258
|
},
|
|
1255
1259
|
async speak(u) {
|
|
1256
1260
|
var g, p, S;
|
|
1257
|
-
function
|
|
1261
|
+
function y() {
|
|
1258
1262
|
if (typeof u == "string") {
|
|
1259
1263
|
if (!l.presenter.voice)
|
|
1260
1264
|
throw new Error("Presenter voice is not initialized");
|
|
@@ -1277,9 +1281,9 @@ async function Lt(e, t) {
|
|
|
1277
1281
|
}
|
|
1278
1282
|
return u;
|
|
1279
1283
|
}
|
|
1280
|
-
const v =
|
|
1284
|
+
const v = y();
|
|
1281
1285
|
if (s.track("agent-speak", v), N.update(), n.messages && v.type === "text" && (n.messages.push({
|
|
1282
|
-
id:
|
|
1286
|
+
id: q(),
|
|
1283
1287
|
role: "assistant",
|
|
1284
1288
|
content: v.input,
|
|
1285
1289
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -1299,29 +1303,29 @@ async function Lt(e, t) {
|
|
|
1299
1303
|
async interrupt({ type: u }) {
|
|
1300
1304
|
var v, T, g;
|
|
1301
1305
|
Ge(n.streamingManager, (v = n.streamingManager) == null ? void 0 : v.streamType, r);
|
|
1302
|
-
const
|
|
1306
|
+
const y = n.messages[n.messages.length - 1];
|
|
1303
1307
|
s.track("agent-video-interrupt", {
|
|
1304
1308
|
type: u || "click",
|
|
1305
1309
|
video_duration_to_interrupt: ie.get(!0),
|
|
1306
1310
|
message_duration_to_interrupt: N.get(!0)
|
|
1307
|
-
}),
|
|
1311
|
+
}), y.interrupted = !0, (g = (T = t.callbacks).onNewMessage) == null || g.call(T, [...n.messages], "answer"), et(n.streamingManager, r);
|
|
1308
1312
|
}
|
|
1309
1313
|
};
|
|
1310
1314
|
}
|
|
1311
1315
|
export {
|
|
1312
|
-
|
|
1316
|
+
O as A,
|
|
1313
1317
|
I as C,
|
|
1314
1318
|
Le as D,
|
|
1315
|
-
|
|
1319
|
+
be as K,
|
|
1316
1320
|
Te as P,
|
|
1317
1321
|
je as R,
|
|
1318
1322
|
W as S,
|
|
1319
1323
|
de as T,
|
|
1320
1324
|
_e as U,
|
|
1321
|
-
V,
|
|
1325
|
+
H as V,
|
|
1322
1326
|
Me as W,
|
|
1323
1327
|
ct as a,
|
|
1324
|
-
|
|
1328
|
+
Z as b,
|
|
1325
1329
|
ke as c,
|
|
1326
1330
|
te as d,
|
|
1327
1331
|
w as e,
|
|
@@ -1331,10 +1335,10 @@ export {
|
|
|
1331
1335
|
Lt as i,
|
|
1332
1336
|
Ae as j,
|
|
1333
1337
|
_ as k,
|
|
1334
|
-
|
|
1335
|
-
|
|
1338
|
+
V as l,
|
|
1339
|
+
Pe as m,
|
|
1336
1340
|
he as n,
|
|
1337
|
-
|
|
1341
|
+
bt as o,
|
|
1338
1342
|
Be as p,
|
|
1339
1343
|
$e as q
|
|
1340
1344
|
};
|