@d-id/client-sdk 1.2.0-staging.339 → 1.2.1-staging.342

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,6 +1,6 @@
1
1
  var Ye = Object.defineProperty;
2
2
  var Qe = (e, t, r) => t in e ? Ye(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var ce = (e, t, r) => Qe(e, typeof t != "symbol" ? t + "" : t, r);
3
+ var Z = (e, t, r) => Qe(e, typeof t != "symbol" ? t + "" : t, r);
4
4
  class G extends Error {
5
5
  constructor(t, r = "Error", a) {
6
6
  super(t), this.kind = r, this.originalError = a, Object.setPrototypeOf(this, new.target.prototype);
@@ -14,7 +14,7 @@ class G extends Error {
14
14
  };
15
15
  }
16
16
  }
17
- function gr(e) {
17
+ function hr(e) {
18
18
  return e instanceof Error && typeof e.kind == "string";
19
19
  }
20
20
  class Ze extends G {
@@ -39,9 +39,9 @@ class ze extends G {
39
39
  constructor(r, a, c = {}) {
40
40
  const s = tt(a);
41
41
  super(((s == null ? void 0 : s.description) ?? a).slice(0, 256), (s == null ? void 0 : s.kind) ?? "HttpError");
42
- ce(this, "status");
43
- ce(this, "url");
44
- ce(this, "method");
42
+ Z(this, "status");
43
+ Z(this, "url");
44
+ Z(this, "method");
45
45
  this.status = r, this.url = c.url, this.method = c.method;
46
46
  }
47
47
  toJson() {
@@ -54,8 +54,18 @@ class ze extends G {
54
54
  }
55
55
  }
56
56
  class rt extends G {
57
- constructor(t) {
58
- super("Network request failed", "NetworkError", t);
57
+ constructor(r, a = {}) {
58
+ super("Network request failed", "NetworkError", r);
59
+ Z(this, "endpoint");
60
+ Z(this, "method");
61
+ this.endpoint = a.url, this.method = a.method;
62
+ }
63
+ toJson() {
64
+ return {
65
+ ...super.toJson(),
66
+ ...this.endpoint ? { endpoint: this.endpoint } : {},
67
+ ...this.method ? { method: this.method } : {}
68
+ };
59
69
  }
60
70
  }
61
71
  class Ne extends G {
@@ -74,7 +84,7 @@ class nt extends G {
74
84
  }
75
85
  }
76
86
  var at = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(at || {}), st = /* @__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))(st || {}), it = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(it || {}), ot = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(ot || {}), A = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e.Off = "Off", e))(A || {}), z = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Transcribe = "transcribe", e.Complete = "done", e))(z || {}), ct = /* @__PURE__ */ ((e) => (e.KnowledgeProcessing = "knowledge/processing", e.KnowledgeIndexing = "knowledge/indexing", e.KnowledgeFailed = "knowledge/error", e.KnowledgeDone = "knowledge/done", e))(ct || {}), dt = /* @__PURE__ */ ((e) => (e.Knowledge = "knowledge", e.Document = "document", e.Record = "record", e))(dt || {}), lt = /* @__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))(lt || {}), Fe = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e.Expressive = "expressive", e))(Fe || {});
77
- const hr = (e) => {
87
+ const pr = (e) => {
78
88
  switch (e) {
79
89
  case "clip":
80
90
  return "clip";
@@ -86,8 +96,8 @@ const hr = (e) => {
86
96
  throw new Error(`Unknown video type: ${e}`);
87
97
  }
88
98
  };
89
- var S = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(S || {}), te = /* @__PURE__ */ ((e) => (e.Strong = "STRONG", e.Weak = "WEAK", e.Unknown = "UNKNOWN", e))(te || {}), ne = /* @__PURE__ */ ((e) => (e.Idle = "IDLE", e.Loading = "LOADING", e.Talking = "TALKING", e.ToolActive = "TOOL_ACTIVE", e))(ne || {}), x = /* @__PURE__ */ ((e) => (e.ChatAnswer = "chat/answer", e.ChatPartial = "chat/partial", e.ChatAudioTranscribed = "chat/audio-transcribed", e.StreamDone = "stream/done", e.StreamStarted = "stream/started", e.StreamFailed = "stream/error", e.StreamReady = "stream/ready", e.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.ToolCallStarted = "tool-call/started", e.ToolCallDone = "tool-call/done", e.ToolCallError = "tool-call/error", e))(x || {}), b = /* @__PURE__ */ ((e) => (e.New = "new", e.Fail = "fail", e.Connected = "connected", e.Connecting = "connecting", e.Closed = "closed", e.Completed = "completed", e.Disconnecting = "disconnecting", e.Disconnected = "disconnected", e))(b || {}), W = /* @__PURE__ */ ((e) => (e.Legacy = "legacy", e.Fluent = "fluent", e))(W || {}), pe = /* @__PURE__ */ ((e) => (e.Livekit = "livekit", e))(pe || {}), ut = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.AzureOpenAi = "azure-openai", e.Microsoft = "microsoft", e.Afflorithmics = "afflorithmics", e.Elevenlabs = "elevenlabs", e))(ut || {}), mt = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e))(mt || {});
90
- const pr = (...e) => {
99
+ var S = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(S || {}), re = /* @__PURE__ */ ((e) => (e.Strong = "STRONG", e.Weak = "WEAK", e.Unknown = "UNKNOWN", e))(re || {}), ae = /* @__PURE__ */ ((e) => (e.Idle = "IDLE", e.Loading = "LOADING", e.Talking = "TALKING", e.ToolActive = "TOOL_ACTIVE", e))(ae || {}), x = /* @__PURE__ */ ((e) => (e.ChatAnswer = "chat/answer", e.ChatPartial = "chat/partial", e.ChatAudioTranscribed = "chat/audio-transcribed", e.StreamDone = "stream/done", e.StreamStarted = "stream/started", e.StreamFailed = "stream/error", e.StreamReady = "stream/ready", e.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.ToolCallStarted = "tool-call/started", e.ToolCallDone = "tool-call/done", e.ToolCallError = "tool-call/error", e))(x || {}), b = /* @__PURE__ */ ((e) => (e.New = "new", e.Fail = "fail", e.Connected = "connected", e.Connecting = "connecting", e.Closed = "closed", e.Completed = "completed", e.Disconnecting = "disconnecting", e.Disconnected = "disconnected", e))(b || {}), W = /* @__PURE__ */ ((e) => (e.Legacy = "legacy", e.Fluent = "fluent", e))(W || {}), pe = /* @__PURE__ */ ((e) => (e.Livekit = "livekit", e))(pe || {}), ut = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.AzureOpenAi = "azure-openai", e.Microsoft = "microsoft", e.Afflorithmics = "afflorithmics", e.Elevenlabs = "elevenlabs", e))(ut || {}), mt = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e))(mt || {});
100
+ const wr = (...e) => {
91
101
  }, Ve = (e) => new Promise((t) => setTimeout(t, e)), Q = (e = 16) => {
92
102
  const t = new Uint8Array(e);
93
103
  return window.crypto.getRandomValues(t), Array.from(t, (r) => r.toString(16).padStart(2, "0")).join("").slice(0, 13);
@@ -169,7 +179,7 @@ function Rt(e) {
169
179
  return c < e.length && a.push({ type: "text", text: e.slice(c) }), a;
170
180
  }
171
181
  let Ee = "", ue = [];
172
- function re(e) {
182
+ function ne(e) {
173
183
  return e === Ee || (Ee = e, ue = Rt(e)), ue;
174
184
  }
175
185
  function Dt(e, t) {
@@ -229,7 +239,7 @@ function He(e, t = le, r, a) {
229
239
  } catch (u) {
230
240
  if ((u == null ? void 0 : u.name) === "AbortError")
231
241
  throw u;
232
- const m = new rt(u);
242
+ const m = new rt(u, { url: s, method: i.method ?? "GET" });
233
243
  throw n || r == null || r(m, { url: s, options: i }), m;
234
244
  }
235
245
  if (!d.ok) {
@@ -358,8 +368,8 @@ function Te(e) {
358
368
  function Ae(e) {
359
369
  return e instanceof G ? e.toJson() : { kind: "UnknownError", message: Tt(e) || "UnknownError" };
360
370
  }
361
- const xt = "https://api-js.mixpanel.com/track/?verbose=1&ip=1";
362
- function Lt(e) {
371
+ const xt = "1.2.1-staging.342", Lt = "https://api-js.mixpanel.com/track/?verbose=1&ip=1";
372
+ function Pt(e) {
363
373
  const t = window != null && window.hasOwnProperty("DID_AGENTS_API") ? "agents-ui" : "agents-sdk", r = {};
364
374
  return {
365
375
  token: e.token || "testKey",
@@ -391,6 +401,8 @@ function Lt(e) {
391
401
  ...n,
392
402
  agentId: this.agentId,
393
403
  source: t,
404
+ emittedBy: "agents-sdk",
405
+ sdkVersion: xt,
394
406
  token: this.token,
395
407
  time: i,
396
408
  $insert_id: this.getRandom(),
@@ -403,7 +415,7 @@ function Lt(e) {
403
415
  ])
404
416
  })
405
417
  };
406
- return fetch(xt, d).catch((u) => console.error("Analytics tracking error:", u)), Promise.resolve();
418
+ return fetch(Lt, d).catch((u) => console.error("Analytics tracking error:", u)), Promise.resolve();
407
419
  },
408
420
  linkTrack(a, c, s, o) {
409
421
  r[a] || (r[a] = { events: {}, resolvedDependencies: [] }), o.includes(s) || o.push(s);
@@ -440,10 +452,10 @@ async function qe(e, t, r, a, c = !1, s) {
440
452
  mode: a
441
453
  })), { chat: s, chatMode: (s == null ? void 0 : s.chat_mode) ?? a };
442
454
  }
443
- function Pt(e) {
455
+ function jt(e) {
444
456
  return e && e.length > 0 ? e : [];
445
457
  }
446
- function jt(e) {
458
+ function Bt(e) {
447
459
  return new Promise((t, r) => {
448
460
  const { callbacks: a, host: c, auth: s, externalId: o } = e, { onMessage: n = null, onOpen: i = null, onClose: d = null, onError: u = null } = a || {}, f = new WebSocket(`${c}?authorization=${encodeURIComponent(Ue(s, o))}`);
449
461
  f.onmessage = n, f.onclose = d, f.onerror = (m) => {
@@ -453,12 +465,12 @@ function jt(e) {
453
465
  };
454
466
  });
455
467
  }
456
- async function Bt(e) {
468
+ async function $t(e) {
457
469
  const { retries: t = 1 } = e;
458
470
  let r = null;
459
471
  for (let a = 0; (r == null ? void 0 : r.readyState) !== WebSocket.OPEN; a++)
460
472
  try {
461
- r = await jt(e);
473
+ r = await Bt(e);
462
474
  } catch (c) {
463
475
  if (a === t)
464
476
  throw c;
@@ -466,8 +478,8 @@ async function Bt(e) {
466
478
  }
467
479
  return r;
468
480
  }
469
- async function $t(e, t, r, a) {
470
- const c = r != null && r.onMessage ? [r.onMessage] : [], s = await Bt({
481
+ async function zt(e, t, r, a) {
482
+ const c = r != null && r.onMessage ? [r.onMessage] : [], s = await $t({
471
483
  auth: e,
472
484
  host: t,
473
485
  externalId: a,
@@ -496,22 +508,22 @@ function xe(e) {
496
508
  r += e[t++];
497
509
  return r;
498
510
  }
499
- function zt(e, t, r) {
511
+ function Nt(e, t, r) {
500
512
  if (!e.content)
501
513
  return;
502
514
  const a = {
503
515
  id: e.id || `user-${Date.now()}`,
504
516
  role: e.role,
505
517
  content: e.content,
506
- parts: re(e.content),
518
+ parts: ne(e.content),
507
519
  created_at: e.created_at || (/* @__PURE__ */ new Date()).toISOString(),
508
520
  transcribed: !0
509
521
  };
510
522
  t.messages.push(a), r == null || r([...t.messages], "user");
511
523
  }
512
- function Nt(e, t, r, a, c, s, o) {
524
+ function Ft(e, t, r, a, c, s, o) {
513
525
  if (e === z.Transcribe && t.content) {
514
- zt(t, a, c);
526
+ Nt(t, a, c);
515
527
  return;
516
528
  }
517
529
  if (!(e === z.Partial || e === z.Answer))
@@ -541,9 +553,9 @@ function Nt(e, t, r, a, c, s, o) {
541
553
  !!(f && f.length < y.length) && (u.interrupted = !0), r.answer = f;
542
554
  }
543
555
  const w = xe(r);
544
- (u.content !== w || e === z.Answer) && (u.content = w, u.parts = re(w), c == null || c([...a.messages], e));
556
+ (u.content !== w || e === z.Answer) && (u.content = w, u.parts = ne(w), c == null || c([...a.messages], e));
545
557
  }
546
- function Ft(e, t, r, a, c) {
558
+ function Vt(e, t, r, a, c) {
547
559
  const s = {}, o = () => {
548
560
  for (const d of Object.keys(s))
549
561
  delete s[d];
@@ -559,7 +571,7 @@ function Ft(e, t, r, a, c) {
559
571
  var f, m;
560
572
  if ("content" in u) {
561
573
  const w = d === x.ChatAnswer ? z.Answer : d === x.ChatAudioTranscribed ? z.Transcribe : d;
562
- Nt(
574
+ Ft(
563
575
  w,
564
576
  u,
565
577
  s,
@@ -590,7 +602,7 @@ function Ft(e, t, r, a, c) {
590
602
  }
591
603
  };
592
604
  }
593
- function Vt(e, t, r, a) {
605
+ function Jt(e, t, r, a) {
594
606
  const c = He(e, `${t}/agents/${r}`, a);
595
607
  return {
596
608
  createStream(s, o) {
@@ -627,8 +639,8 @@ function Vt(e, t, r, a) {
627
639
  }
628
640
  };
629
641
  }
630
- const Jt = (e, t) => (r, a) => e && console.log(`[${t}] ${r}`, a ?? "");
631
- function Ut(e, t, r) {
642
+ const Ut = (e, t) => (r, a) => e && console.log(`[${t}] ${r}`, a ?? "");
643
+ function Kt(e, t, r) {
632
644
  const a = (t.timestamp - e.timestamp) / 1e3;
633
645
  return {
634
646
  duration: a,
@@ -648,7 +660,7 @@ function Ut(e, t, r) {
648
660
  lowFpsCount: r
649
661
  };
650
662
  }
651
- function Kt(e) {
663
+ function Wt(e) {
652
664
  return e.filter(
653
665
  (t) => t.freezeCount > 0 || t.framesPerSecond < 21 || t.framesDropped > 0 || t.packetsLost > 0
654
666
  ).map((t) => {
@@ -659,7 +671,7 @@ function Kt(e) {
659
671
  };
660
672
  });
661
673
  }
662
- function Wt(e) {
674
+ function Ht(e) {
663
675
  var o;
664
676
  let t = "", r = 0, a = null;
665
677
  const c = /* @__PURE__ */ new Map();
@@ -746,14 +758,14 @@ function Le(e, t, r) {
746
758
  framesPerSecond: i.framesPerSecond,
747
759
  freezeCount: i.freezeCount - e[d - 1].freezeCount,
748
760
  freezeDuration: i.freezeDuration - e[d - 1].freezeDuration
749
- }), c = Kt(a), s = c.reduce((i, d) => i + (d.causes.includes("low fps") ? 1 : 0), 0), o = a.filter((i) => !!i.avgJitterDelayInInterval).map((i) => i.avgJitterDelayInInterval), n = a.filter((i) => !!i.rtt).map((i) => i.rtt);
761
+ }), c = Wt(a), s = c.reduce((i, d) => i + (d.causes.includes("low fps") ? 1 : 0), 0), o = a.filter((i) => !!i.avgJitterDelayInInterval).map((i) => i.avgJitterDelayInInterval), n = a.filter((i) => !!i.rtt).map((i) => i.rtt);
750
762
  return {
751
763
  webRTCStats: {
752
764
  anomalies: c,
753
765
  minRtt: Math.min(...n),
754
766
  avgRtt: _e(n),
755
767
  maxRtt: Math.max(...n),
756
- aggregateReport: Ut(e[0], e[e.length - 1], s),
768
+ aggregateReport: Kt(e[0], e[e.length - 1], s),
757
769
  minJitterDelayInInterval: Math.min(...o),
758
770
  maxJitterDelayInInterval: Math.max(...o),
759
771
  avgJitterDelayInInterval: _e(o)
@@ -768,25 +780,25 @@ function Ge(e, t) {
768
780
  return r;
769
781
  return null;
770
782
  }
771
- const ee = 10;
772
- function wr(e, t) {
783
+ const te = 10;
784
+ function vr(e, t) {
773
785
  let r = !1, a = !1, c = null, s = 0, o = 0, n = {};
774
786
  async function i() {
775
787
  if (r) {
776
788
  try {
777
789
  const d = await e();
778
790
  if (!d) {
779
- c = setTimeout(i, ee);
791
+ c = setTimeout(i, te);
780
792
  return;
781
793
  }
782
794
  const u = Ge(d, "audio");
783
795
  if (!u) {
784
- c = setTimeout(i, ee);
796
+ c = setTimeout(i, te);
785
797
  return;
786
798
  }
787
799
  const f = u.totalAudioEnergy ?? 0, m = u.totalSamplesReceived ?? 0;
788
800
  if (!a) {
789
- s = f, o = m, a = !0, c = setTimeout(i, ee);
801
+ s = f, o = m, a = !0, c = setTimeout(i, te);
790
802
  return;
791
803
  }
792
804
  const w = f - s, y = m - o;
@@ -796,20 +808,20 @@ function wr(e, t) {
796
808
  }
797
809
  } catch {
798
810
  }
799
- r && (c = setTimeout(i, ee));
811
+ r && (c = setTimeout(i, te));
800
812
  }
801
813
  }
802
814
  return {
803
815
  arm(d = {}) {
804
- n = d, r = !0, a = !1, performance.now(), c !== null && clearTimeout(c), c = setTimeout(i, ee);
816
+ n = d, r = !0, a = !1, performance.now(), c !== null && clearTimeout(c), c = setTimeout(i, te);
805
817
  },
806
818
  destroy() {
807
819
  r = !1, c !== null && (clearTimeout(c), c = null);
808
820
  }
809
821
  };
810
822
  }
811
- const de = 100, Ht = Math.max(Math.ceil(400 / de), 1), Ot = 0.25, qt = 0.28;
812
- function Gt() {
823
+ const de = 100, Ot = Math.max(Math.ceil(400 / de), 1), qt = 0.25, Gt = 0.28;
824
+ function Xt() {
813
825
  let e = 0, t, r, a = 0;
814
826
  return (c) => {
815
827
  const s = Ge(c, "video");
@@ -825,17 +837,17 @@ function Gt() {
825
837
  return e = i, { isReceiving: d, avgJitterDelayInInterval: a, freezeCount: s.freezeCount };
826
838
  };
827
839
  }
828
- function Xt(e, t, r, a, c) {
829
- let s = null, o = [], n, i = 0, d = !1, u = te.Unknown, f = te.Unknown, m = 0, w = 0;
830
- const y = Gt();
840
+ function Yt(e, t, r, a, c) {
841
+ let s = null, o = [], n, i = 0, d = !1, u = re.Unknown, f = re.Unknown, m = 0, w = 0;
842
+ const y = Xt();
831
843
  async function j() {
832
844
  const M = await e();
833
845
  if (!M)
834
846
  return;
835
- const { isReceiving: _, avgJitterDelayInInterval: L, freezeCount: E } = y(M), X = Wt(M);
847
+ const { isReceiving: _, avgJitterDelayInInterval: L, freezeCount: E } = y(M), X = Ht(M);
836
848
  if (_)
837
- i = 0, m = E - w, f = L < Ot ? te.Strong : L > qt && m > 1 ? te.Weak : u, f !== u && (c == null || c(f), u = f, w += m, m = 0), d || (a == null || a(S.Start), n = o[o.length - 1], o = [], d = !0), o.push(X);
838
- else if (d && (i++, i >= Ht)) {
849
+ i = 0, m = E - w, f = L < qt ? re.Strong : L > Gt && m > 1 ? re.Weak : u, f !== u && (c == null || c(f), u = f, w += m, m = 0), d || (a == null || a(S.Start), n = o[o.length - 1], o = [], d = !0), o.push(X);
850
+ else if (d && (i++, i >= Ot)) {
839
851
  const H = Le(o, de, n);
840
852
  a == null || a(S.Stop, H), t() || r(), w = E, d = !1;
841
853
  }
@@ -850,7 +862,7 @@ function Xt(e, t, r, a, c) {
850
862
  getReport: () => Le(o, de, n)
851
863
  };
852
864
  }
853
- const Yt = (window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection).bind(window);
865
+ const Qt = (window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection).bind(window);
854
866
  function Pe(e) {
855
867
  switch (e) {
856
868
  case "connected":
@@ -871,7 +883,7 @@ function Pe(e) {
871
883
  return b.New;
872
884
  }
873
885
  }
874
- const Qt = (e) => (t) => {
886
+ const Zt = (e) => (t) => {
875
887
  const [r, a = ""] = t.split(/:(.+)/);
876
888
  try {
877
889
  const c = JSON.parse(a);
@@ -880,7 +892,7 @@ const Qt = (e) => (t) => {
880
892
  return e("Failed to parse data channel message, returning data as string", { subject: r, rawData: a, error: c }), { subject: r, data: a };
881
893
  }
882
894
  };
883
- function Zt({
895
+ function er({
884
896
  statsSignal: e,
885
897
  dataChannelSignal: t,
886
898
  onVideoStateChange: r,
@@ -889,7 +901,7 @@ function Zt({
889
901
  }) {
890
902
  e === S.Start && t === S.Start ? (c("CALLBACK: onVideoStateChange(Start)"), r == null || r(S.Start)) : e === S.Stop && t === S.Stop && (c("CALLBACK: onVideoStateChange(Stop)"), r == null || r(S.Stop, a));
891
903
  }
892
- function er({
904
+ function tr({
893
905
  statsSignal: e,
894
906
  dataChannelSignal: t,
895
907
  onVideoStateChange: r,
@@ -897,7 +909,7 @@ function er({
897
909
  report: c,
898
910
  log: s
899
911
  }) {
900
- e === S.Start ? (s("CALLBACK: onVideoStateChange(Start)"), r == null || r(S.Start)) : e === S.Stop && (s("CALLBACK: onVideoStateChange(Stop)"), r == null || r(S.Stop, c)), t === S.Start ? a == null || a(ne.Talking) : t === S.Stop && (a == null || a(ne.Idle));
912
+ e === S.Start ? (s("CALLBACK: onVideoStateChange(Start)"), r == null || r(S.Start)) : e === S.Stop && (s("CALLBACK: onVideoStateChange(Stop)"), r == null || r(S.Stop, c)), t === S.Start ? a == null || a(ae.Talking) : t === S.Stop && (a == null || a(ae.Idle));
901
913
  }
902
914
  function je({
903
915
  statsSignal: e,
@@ -908,7 +920,7 @@ function je({
908
920
  report: s,
909
921
  log: o
910
922
  }) {
911
- c === W.Legacy ? Zt({ statsSignal: e, dataChannelSignal: t, onVideoStateChange: r, report: s, log: o }) : c === W.Fluent && er({
923
+ c === W.Legacy ? er({ statsSignal: e, dataChannelSignal: t, onVideoStateChange: r, report: s, log: o }) : c === W.Fluent && tr({
912
924
  statsSignal: e,
913
925
  dataChannelSignal: t,
914
926
  onVideoStateChange: r,
@@ -917,11 +929,11 @@ function je({
917
929
  log: o
918
930
  });
919
931
  }
920
- async function tr(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le, analytics: o }, n) {
932
+ async function rr(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le, analytics: o }, n) {
921
933
  var F;
922
- const i = Jt(r, "WebRTCStreamingManager"), d = Qt(i);
934
+ const i = Ut(r, "WebRTCStreamingManager"), d = Zt(i);
923
935
  let u = !1, f = !1, m = S.Stop, w = S.Stop;
924
- const { startConnection: y, sendStreamRequest: j, close: M, createStream: _, addIceCandidate: L } = Vt(
936
+ const { startConnection: y, sendStreamRequest: j, close: M, createStream: _, addIceCandidate: L } = Jt(
925
937
  c,
926
938
  s,
927
939
  e,
@@ -931,24 +943,24 @@ async function tr(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le,
931
943
  offer: X,
932
944
  ice_servers: H,
933
945
  session_id: V,
934
- fluent: ae,
946
+ fluent: se,
935
947
  interrupt_enabled: Y
936
948
  } = await _(t, n);
937
949
  (F = a.onStreamCreated) == null || F.call(a, { stream_id: E, session_id: V, agent_id: e });
938
- const D = new Yt({ iceServers: H }), O = D.createDataChannel("JanusDataChannel");
950
+ const D = new Qt({ iceServers: H }), O = D.createDataChannel("JanusDataChannel");
939
951
  if (!V)
940
952
  throw new Error("Could not create session_id");
941
- const J = ae ? W.Fluent : W.Legacy;
953
+ const J = se ? W.Fluent : W.Legacy;
942
954
  o.enrich({
943
955
  "stream-type": J
944
956
  });
945
- const se = t.stream_warmup && !ae, ie = () => u, Z = () => {
957
+ const ie = t.stream_warmup && !se, oe = () => u, ee = () => {
946
958
  var g;
947
959
  u = !0, f && (i("CALLBACK: onConnectionStateChange(Connected)"), (g = a.onConnectionStateChange) == null || g.call(a, b.Connected));
948
- }, l = Xt(
960
+ }, l = Yt(
949
961
  () => D.getStats(),
950
- ie,
951
- Z,
962
+ oe,
963
+ ee,
952
964
  (g, h) => je({
953
965
  statsSignal: w = g,
954
966
  dataChannelSignal: J === W.Legacy ? m : void 0,
@@ -981,7 +993,7 @@ async function tr(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le,
981
993
  (h = a.onError) == null || h.call(a, I, { streamId: E });
982
994
  }
983
995
  }, O.onopen = () => {
984
- f = !0, (!se || u) && Z();
996
+ f = !0, (!ie || u) && ee();
985
997
  };
986
998
  let p = null;
987
999
  const v = (g) => {
@@ -1069,7 +1081,7 @@ async function tr(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le,
1069
1081
  } catch (I) {
1070
1082
  i("Error on close stream connection", I);
1071
1083
  }
1072
- (g = a.onAgentActivityStateChange) == null || g.call(a, ne.Idle), l.stop();
1084
+ (g = a.onAgentActivityStateChange) == null || g.call(a, ae.Idle), l.stop();
1073
1085
  }
1074
1086
  },
1075
1087
  sendDataChannelMessage: N,
@@ -1101,18 +1113,18 @@ async function tr(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = le,
1101
1113
  };
1102
1114
  }
1103
1115
  var he = /* @__PURE__ */ ((e) => (e.V1 = "v1", e.V2 = "v2", e))(he || {});
1104
- async function rr(e, t, r, a) {
1116
+ async function nr(e, t, r, a) {
1105
1117
  const c = e.id;
1106
1118
  switch (t.version) {
1107
1119
  case "v1": {
1108
1120
  const { version: s, ...o } = t;
1109
- return tr(c, o, r, a);
1121
+ return rr(c, o, r, a);
1110
1122
  }
1111
1123
  case "v2": {
1112
1124
  const { version: s, ...o } = t;
1113
1125
  switch (o.transport.provider) {
1114
1126
  case pe.Livekit:
1115
- const { createLiveKitStreamingManager: n } = await import("./livekit-manager-DXAfWjwR.js");
1127
+ const { createLiveKitStreamingManager: n } = await import("./livekit-manager-Cn2SQGJF.js");
1116
1128
  return n(c, o, r);
1117
1129
  default:
1118
1130
  throw new Error(`Unsupported transport provider: ${o.transport.provider}`);
@@ -1122,15 +1134,15 @@ async function rr(e, t, r, a) {
1122
1134
  throw new Error(`Invalid stream version: ${t.version}`);
1123
1135
  }
1124
1136
  }
1125
- const nr = "cht";
1126
- function ar() {
1137
+ const ar = "cht";
1138
+ function sr() {
1127
1139
  return {
1128
1140
  transport: {
1129
1141
  provider: pe.Livekit
1130
1142
  }
1131
1143
  };
1132
1144
  }
1133
- function sr(e) {
1145
+ function ir(e) {
1134
1146
  var c, s;
1135
1147
  const { streamOptions: t } = e ?? {}, r = ((c = e == null ? void 0 : e.mixpanelAdditionalProperties) == null ? void 0 : c.plan) !== void 0 ? {
1136
1148
  plan: (s = e.mixpanelAdditionalProperties) == null ? void 0 : s.plan
@@ -1143,16 +1155,16 @@ function sr(e) {
1143
1155
  fluent: t == null ? void 0 : t.fluent
1144
1156
  }, ...r && { end_user_data: r } };
1145
1157
  }
1146
- function ir(e, t) {
1147
- return we(e.presenter.type) ? { version: he.V2, ...ar() } : { version: he.V1, ...sr(t) };
1158
+ function or(e, t) {
1159
+ return we(e.presenter.type) ? { version: he.V2, ...sr() } : { version: he.V1, ...ir(t) };
1148
1160
  }
1149
- function or(e, t, r) {
1161
+ function cr(e, t, r) {
1150
1162
  r.track("agent-connection-state-change", { state: e, ...t && { reason: t } });
1151
1163
  }
1152
- function cr(e, t, r, a, c) {
1153
- c === W.Fluent ? dr(e, t, r, a, c) : lr(e, t, r, a, c);
1154
- }
1155
1164
  function dr(e, t, r, a, c) {
1165
+ c === W.Fluent ? lr(e, t, r, a, c) : ur(e, t, r, a, c);
1166
+ }
1167
+ function lr(e, t, r, a, c) {
1156
1168
  e === S.Start ? a.track("stream-session", { event: "start", "stream-type": c }) : e === S.Stop && a.track("stream-session", {
1157
1169
  event: "stop",
1158
1170
  is_greenscreen: t.presenter.type === "clip" && t.presenter.is_greenscreen,
@@ -1176,7 +1188,7 @@ function Be(e, t, r, a, c) {
1176
1188
  [x.StreamVideoDone]
1177
1189
  );
1178
1190
  }
1179
- function lr(e, t, r, a, c) {
1191
+ function ur(e, t, r, a, c) {
1180
1192
  e === S.Start ? a.linkTrack(
1181
1193
  "agent-video",
1182
1194
  { event: "start", latency: q.get(!0), "stream-type": c },
@@ -1195,7 +1207,7 @@ function lr(e, t, r, a, c) {
1195
1207
  [x.StreamVideoDone]
1196
1208
  );
1197
1209
  }
1198
- function ur(e, t, r) {
1210
+ function mr(e, t, r) {
1199
1211
  const a = {
1200
1212
  call_id: t.call_id,
1201
1213
  name: t.name
@@ -1216,13 +1228,13 @@ function $e(e, t, r, a) {
1216
1228
  return q.reset(), be.update(), new Promise(async (c, s) => {
1217
1229
  try {
1218
1230
  let o, n = !1;
1219
- const i = ir(e, t);
1231
+ const i = or(e, t);
1220
1232
  r.enrich({
1221
1233
  "stream-version": i.version.toString()
1222
1234
  });
1223
1235
  let d = null;
1224
1236
  const u = e.presenter.type === "expressive";
1225
- o = await rr(
1237
+ o = await nr(
1226
1238
  e,
1227
1239
  i,
1228
1240
  {
@@ -1232,11 +1244,11 @@ function $e(e, t, r, a) {
1232
1244
  ...t.callbacks,
1233
1245
  onConnectionStateChange: (f, m) => {
1234
1246
  var w, y;
1235
- (y = (w = t.callbacks).onConnectionStateChange) == null || y.call(w, f), or(f, m, r), f === b.Connected && (o ? c(o) : n = !0);
1247
+ (y = (w = t.callbacks).onConnectionStateChange) == null || y.call(w, f), cr(f, m, r), f === b.Connected && (o ? c(o) : n = !0);
1236
1248
  },
1237
1249
  onVideoStateChange: (f, m) => {
1238
1250
  var w, y;
1239
- (y = (w = t.callbacks).onVideoStateChange) == null || y.call(w, f), cr(
1251
+ (y = (w = t.callbacks).onVideoStateChange) == null || y.call(w, f), dr(
1240
1252
  f,
1241
1253
  e,
1242
1254
  m,
@@ -1246,7 +1258,7 @@ function $e(e, t, r, a) {
1246
1258
  },
1247
1259
  onAgentActivityStateChange: (f) => {
1248
1260
  var m, w;
1249
- (w = (m = t.callbacks).onAgentActivityStateChange) == null || w.call(m, f), f === ne.Talking ? (ge.update(), d = (y) => {
1261
+ (w = (m = t.callbacks).onAgentActivityStateChange) == null || w.call(m, f), f === ae.Talking ? (ge.update(), d = (y) => {
1250
1262
  Be(
1251
1263
  S.Start,
1252
1264
  e,
@@ -1270,7 +1282,7 @@ function $e(e, t, r, a) {
1270
1282
  },
1271
1283
  onToolEvent: ((f, m) => {
1272
1284
  var w, y;
1273
- (y = (w = t.callbacks).onToolEvent) == null || y.call(w, f, m), ur(f, m, r);
1285
+ (y = (w = t.callbacks).onToolEvent) == null || y.call(w, f, m), mr(f, m, r);
1274
1286
  })
1275
1287
  }
1276
1288
  },
@@ -1281,11 +1293,11 @@ function $e(e, t, r, a) {
1281
1293
  }
1282
1294
  });
1283
1295
  }
1284
- async function mr(e, t, r, a, c) {
1296
+ async function fr(e, t, r, a, c) {
1285
1297
  var u, f, m, w;
1286
1298
  const s = async () => {
1287
1299
  if (we(e.presenter.type)) {
1288
- const y = await $e(e, t, a), j = `${nr}_${y.sessionId}`, M = (/* @__PURE__ */ new Date()).toISOString();
1300
+ const y = await $e(e, t, a), j = `${ar}_${y.sessionId}`, M = (/* @__PURE__ */ new Date()).toISOString();
1289
1301
  return { chatResult: {
1290
1302
  chatMode: A.Functional,
1291
1303
  chat: {
@@ -1321,13 +1333,13 @@ async function mr(e, t, r, a, c) {
1321
1333
  }, { chatResult: o, streamingManager: n } = await s(), { chat: i, chatMode: d } = o;
1322
1334
  return d && t.mode !== void 0 && d !== t.mode && (t.mode = d, (f = (u = t.callbacks).onModeChange) == null || f.call(u, d), d !== A.Functional) ? ((w = (m = t.callbacks).onError) == null || w.call(m, new et(d)), n == null || n.disconnect(), { chat: i }) : { chat: i, streamingManager: n };
1323
1335
  }
1324
- async function vr(e, t) {
1325
- var J, se, ie, Z;
1336
+ async function yr(e, t) {
1337
+ var J, ie, oe, ee;
1326
1338
  let r = !0;
1327
1339
  const a = t.mixpanelKey || wt, c = t.wsURL || pt, s = t.baseURL || le, o = t.mode || A.Functional, n = {
1328
1340
  messages: [],
1329
1341
  chatMode: o
1330
- }, i = Lt({
1342
+ }, i = Pt({
1331
1343
  token: a,
1332
1344
  agentId: e,
1333
1345
  isEnabled: t.enableAnalitics,
@@ -1345,11 +1357,11 @@ async function vr(e, t) {
1345
1357
  t.debug = t.debug || ((J = m == null ? void 0 : m.advanced_settings) == null ? void 0 : J.ui_debug_mode);
1346
1358
  const w = we(m.presenter.type);
1347
1359
  i.enrich(_t(m));
1348
- const { onMessage: y, clearQueue: j } = Ft(i, n, t, m, () => {
1360
+ const { onMessage: y, clearQueue: j } = Vt(i, n, t, m, () => {
1349
1361
  var l, p, v;
1350
1362
  (l = n.socketManager) == null || l.disconnect(), (v = (p = t.callbacks).onConnectionStateChange) == null || v.call(p, b.Disconnected);
1351
1363
  });
1352
- n.messages = Pt(t.initialMessages), (ie = (se = t.callbacks).onNewMessage) == null || ie.call(se, [...n.messages], "answer");
1364
+ n.messages = jt(t.initialMessages), (oe = (ie = t.callbacks).onNewMessage) == null || oe.call(ie, [...n.messages], "answer");
1353
1365
  const M = (l) => {
1354
1366
  }, _ = ({ type: l }) => {
1355
1367
  var v, C, k, R;
@@ -1388,20 +1400,20 @@ async function vr(e, t) {
1388
1400
  var p, v;
1389
1401
  L.delete(l), (v = (p = n.streamingManager) == null ? void 0 : p.unregisterRpcMethod) == null || v.call(p, l);
1390
1402
  }
1391
- const ae = Date.now();
1403
+ const se = Date.now();
1392
1404
  Te(() => {
1393
- i.track("agent-sdk", { event: "loaded", ...Et(m) }, ae);
1405
+ i.track("agent-sdk", { event: "loaded", ...Et(m) }, se);
1394
1406
  });
1395
1407
  async function Y(l) {
1396
1408
  var P, N, F, g, h, I, B;
1397
1409
  ft(), (N = (P = t.callbacks).onConnectionStateChange) == null || N.call(P, b.Connecting), q.reset(), l && !r && (delete n.chat, (g = (F = t.callbacks).onNewMessage) == null || g.call(F, [...n.messages], "answer"));
1398
- const p = o === A.DirectPlayback || w ? Promise.resolve(void 0) : $t(
1410
+ const p = o === A.DirectPlayback || w ? Promise.resolve(void 0) : zt(
1399
1411
  t.auth,
1400
1412
  c,
1401
1413
  { onMessage: y, onError: t.callbacks.onError },
1402
1414
  t.externalId
1403
1415
  ), v = fe(
1404
- () => mr(
1416
+ () => fr(
1405
1417
  m,
1406
1418
  {
1407
1419
  ...t,
@@ -1451,7 +1463,7 @@ async function vr(e, t) {
1451
1463
  var l;
1452
1464
  return ((l = n.streamingManager) == null ? void 0 : l.interruptAvailable) ?? !1;
1453
1465
  },
1454
- starterMessages: ((Z = m.knowledge) == null ? void 0 : Z.starter_message) || [],
1466
+ starterMessages: ((ee = m.knowledge) == null ? void 0 : ee.starter_message) || [],
1455
1467
  getSTTToken: () => f.getSTTToken(m.id),
1456
1468
  changeMode: O,
1457
1469
  enrichAnalytics: i.enrich,
@@ -1551,7 +1563,7 @@ async function vr(e, t) {
1551
1563
  chatMode: n.chatMode,
1552
1564
  streamId: (T = n.streamingManager) == null ? void 0 : T.streamId,
1553
1565
  sessionId: (U = n.streamingManager) == null ? void 0 : U.sessionId,
1554
- messages: g.map(({ matches: Xe, ...oe }) => oe)
1566
+ messages: g.map(({ matches: Xe, ...ce }) => ce)
1555
1567
  },
1556
1568
  {
1557
1569
  ...Oe(n.chatMode),
@@ -1561,8 +1573,8 @@ async function vr(e, t) {
1561
1573
  }, {
1562
1574
  limit: 2,
1563
1575
  shouldRetryFn: (T) => {
1564
- var oe, ye, Ce, Se;
1565
- const U = (oe = T == null ? void 0 : T.message) == null ? void 0 : oe.includes("missing or invalid session_id");
1576
+ var ce, ye, Ce, Se;
1577
+ const U = (ce = T == null ? void 0 : T.message) == null ? void 0 : ce.includes("missing or invalid session_id");
1566
1578
  return !((ye = T == null ? void 0 : T.message) == null ? void 0 : ye.includes("Stream Error")) && !U ? ((Se = (Ce = t.callbacks).onError) == null || Se.call(Ce, T), !1) : !0;
1567
1579
  },
1568
1580
  onRetry: async () => {
@@ -1575,7 +1587,7 @@ async function vr(e, t) {
1575
1587
  id: Q(),
1576
1588
  role: "user",
1577
1589
  content: l,
1578
- parts: re(l),
1590
+ parts: ne(l),
1579
1591
  created_at: new Date(q.update()).toISOString()
1580
1592
  }), (R = (k = t.callbacks).onNewMessage) == null || R.call(k, [...n.messages], "user");
1581
1593
  const g = await v(), h = await C([...n.messages], g);
@@ -1583,7 +1595,7 @@ async function vr(e, t) {
1583
1595
  id: Q(),
1584
1596
  role: "assistant",
1585
1597
  content: h.result,
1586
- parts: re(h.result),
1598
+ parts: ne(h.result),
1587
1599
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1588
1600
  context: h.context,
1589
1601
  matches: h.matches
@@ -1663,7 +1675,7 @@ async function vr(e, t) {
1663
1675
  id: Q(),
1664
1676
  role: "assistant",
1665
1677
  content: v.input,
1666
- parts: re(v.input),
1678
+ parts: ne(v.input),
1667
1679
  created_at: (/* @__PURE__ */ new Date()).toISOString()
1668
1680
  }), (R = (k = t.callbacks).onNewMessage) == null || R.call(k, [...n.messages], "answer")), Ct(n.chatMode))
1669
1681
  return {
@@ -1684,7 +1696,7 @@ async function vr(e, t) {
1684
1696
  };
1685
1697
  }
1686
1698
  export {
1687
- ne as A,
1699
+ ae as A,
1688
1700
  G as B,
1689
1701
  z as C,
1690
1702
  lt as D,
@@ -1698,29 +1710,30 @@ export {
1698
1710
  at as U,
1699
1711
  $ as V,
1700
1712
  nt as W,
1701
- Jt as a,
1713
+ Ut as a,
1702
1714
  W as b,
1703
1715
  He as c,
1704
1716
  le as d,
1705
1717
  Ne as e,
1706
1718
  b as f,
1707
- te as g,
1708
- Xt as h,
1709
- wr as i,
1719
+ re as g,
1720
+ Yt as h,
1721
+ vr as i,
1710
1722
  S as j,
1711
1723
  it as k,
1712
1724
  q as l,
1713
1725
  Ze as m,
1714
- pr as n,
1726
+ wr as n,
1715
1727
  A as o,
1716
1728
  et as p,
1717
1729
  ut as q,
1718
- ct as r,
1719
- Fe as s,
1730
+ xt as r,
1731
+ ct as s,
1720
1732
  Ae as t,
1721
- mt as u,
1722
- vr as v,
1723
- gr as w,
1733
+ Fe as u,
1734
+ mt as v,
1735
+ yr as w,
1724
1736
  hr as x,
1725
- Rt as y
1737
+ pr as y,
1738
+ Rt as z
1726
1739
  };