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

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,17 +1,17 @@
1
- import { c as De, C as O, S as p, a as Fe, b as Ne, A as m, d as Ue, l as de, e as v, f as N, g as je, h as xe, i as A, n as Oe } from "./index-OAVAtXjd.js";
2
- function Je(T, L, g, i) {
3
- const M = De(T, `${L}/v2/agents/${g}`, i);
1
+ import { c as De, C as O, S as l, a as Fe, b as Ne, A as m, d as Ue, l as de, e as je, t as xe, f as v, g as U, h as Oe, i as Be, j as A, n as Je } from "./index-CneVgQpS.js";
2
+ function Qe(C, L, g, i) {
3
+ const M = De(C, `${L}/v2/agents/${g}`, i);
4
4
  return {
5
- async createStream(l) {
6
- return M.post("/sessions", l);
5
+ async createStream(p) {
6
+ return M.post("/sessions", p);
7
7
  }
8
8
  };
9
9
  }
10
- const Be = {
11
- [p.ChatAnswer]: O.Answer,
12
- [p.ChatPartial]: O.Partial
10
+ const qe = {
11
+ [l.ChatAnswer]: O.Answer,
12
+ [l.ChatPartial]: O.Partial
13
13
  }, ue = 2e4;
14
- async function Qe() {
14
+ async function ze() {
15
15
  try {
16
16
  return await import("./livekit-client.esm-DypJ_fOm.js");
17
17
  } catch {
@@ -20,63 +20,62 @@ async function Qe() {
20
20
  );
21
21
  }
22
22
  }
23
- const qe = {
24
- excellent: N.Strong,
25
- good: N.Strong,
26
- poor: N.Weak,
27
- lost: N.Unknown,
28
- unknown: N.Unknown
29
- }, U = JSON.stringify({
30
- kind: "InternalServerError",
31
- description: "Stream Error"
32
- });
33
- function pe(T, L, g) {
23
+ const We = {
24
+ excellent: U.Strong,
25
+ good: U.Strong,
26
+ poor: U.Weak,
27
+ lost: U.Unknown,
28
+ unknown: U.Unknown
29
+ }, _ = (C = "Stream Error") => new je(C);
30
+ function le(C, L, g) {
34
31
  var i, M;
35
- throw L("Failed to connect to LiveKit room:", T), (i = g.onConnectionStateChange) == null || i.call(g, v.Fail, "internal:init-error"), (M = g.onError) == null || M.call(g, T, { sessionId: "" }), T;
32
+ throw L("Failed to connect to LiveKit room:", C), (i = g.onConnectionStateChange) == null || i.call(g, v.Fail, "internal:init-error"), (M = g.onError) == null || M.call(g, C, { sessionId: "" }), C;
36
33
  }
37
- async function We(T, L, g) {
34
+ async function Ge(C, L, g) {
38
35
  var re;
39
- const i = Fe(g.debug || !1, "LiveKitStreamingManager"), { Room: M, RoomEvent: l, ConnectionState: k, Track: H } = await Qe(), { callbacks: n, auth: le, baseURL: he, analytics: G } = g;
36
+ const i = Fe(g.debug || !1, "LiveKitStreamingManager"), { Room: M, RoomEvent: p, ConnectionState: b, Track: H } = await ze(), { callbacks: n, auth: pe, baseURL: he, analytics: G } = g;
40
37
  let a = null, w = !1;
41
38
  const X = Ne.Fluent;
42
39
  let R = null;
43
- const P = { isPublishing: !1, publication: null }, J = { isPublishing: !1, publication: null };
44
- let h = null, f = null, j = null, _ = !1;
40
+ const P = { isPublishing: !1, publication: null }, B = { isPublishing: !1, publication: null };
41
+ let h = null, f = null, j = null, D = !1;
45
42
  a = new M({
46
43
  adaptiveStream: !1,
47
44
  // Must be false to use mediaStreamTrack directly
48
45
  dynacast: !0
49
46
  });
50
- let E = null, b = m.Idle, I = !0;
51
- const ge = Je(le, he || Ue, T, n.onError);
52
- let C, $, K, Y = !0;
47
+ let E = null, k = m.Idle, I = !0;
48
+ const ge = Qe(pe, he || Ue, C, n.onError);
49
+ let S, $, K, Y = !0;
53
50
  try {
54
51
  const e = await ge.createStream({
55
52
  transport: L.transport,
56
53
  chat_persist: L.chat_persist ?? !0
57
54
  }), { id: t, session_token: r, session_url: o, interrupt_enabled: c } = e;
58
- (re = n.onStreamCreated) == null || re.call(n, { session_id: t, stream_id: t, agent_id: T }), C = t, $ = r, K = o, Y = c ?? !0, await a.prepareConnection(K, $);
55
+ (re = n.onStreamCreated) == null || re.call(n, { session_id: t, stream_id: t, agent_id: C }), S = t, $ = r, K = o, Y = c ?? !0, await a.prepareConnection(K, $);
59
56
  } catch (e) {
60
- pe(e, i, n);
57
+ le(e, i, n);
61
58
  }
62
- if (!K || !$ || !C)
59
+ if (!K || !$ || !S)
63
60
  return Promise.reject(new Error("Failed to initialize LiveKit stream"));
64
- a.on(l.ConnectionStateChanged, me).on(l.ConnectionQualityChanged, Ce).on(l.ParticipantConnected, Se).on(l.ParticipantDisconnected, Te).on(l.TrackSubscribed, ve).on(l.TrackUnsubscribed, we).on(l.DataReceived, Pe).on(l.MediaDevicesError, Le).on(l.TranscriptionReceived, fe).on(l.EncryptionError, Me).on(l.TrackSubscriptionFailed, ke);
61
+ a.on(p.ConnectionStateChanged, me).on(p.ConnectionQualityChanged, Ce).on(p.ParticipantConnected, Se).on(p.ParticipantDisconnected, ye).on(p.TrackSubscribed, ve).on(p.TrackUnsubscribed, we).on(p.DataReceived, Pe).on(p.MediaDevicesError, Le).on(p.TranscriptionReceived, fe).on(p.EncryptionError, Me).on(p.TrackSubscriptionFailed, be);
65
62
  function fe(e, t) {
66
- t != null && t.isLocal && (de.update(), b === m.Talking && (b = m.Idle));
63
+ t != null && t.isLocal && (de.update(), k === m.Talking && (k = m.Idle));
67
64
  }
68
65
  try {
69
66
  await a.connect(K, $), i("LiveKit room joined successfully"), E = setTimeout(() => {
70
- var e;
67
+ var t;
71
68
  i(
72
69
  `Track subscription timeout - no track subscribed within ${ue / 1e3} seconds after connect`
73
- ), E = null, G.track("connectivity-error", {
74
- error: "Track subscription timeout",
75
- sessionId: C
76
- }), (e = n.onError) == null || e.call(n, new Error("Track subscription timeout"), { sessionId: C }), W("internal:track-subscription-timeout");
70
+ ), E = null;
71
+ const e = _("Track subscription timeout");
72
+ G.track("connectivity-error", {
73
+ error: xe(e),
74
+ sessionId: S
75
+ }), (t = n.onError) == null || t.call(n, e, { sessionId: S }), W("internal:track-subscription-timeout");
77
76
  }, ue);
78
77
  } catch (e) {
79
- pe(e, i, n);
78
+ le(e, i, n);
80
79
  }
81
80
  G.enrich({
82
81
  "stream-type": X
@@ -84,34 +83,34 @@ async function We(T, L, g) {
84
83
  function me(e) {
85
84
  var t, r, o, c;
86
85
  switch (i("Connection state changed:", e), e) {
87
- case k.Connecting:
86
+ case b.Connecting:
88
87
  i("CALLBACK: onConnectionStateChange(Connecting)"), (t = n.onConnectionStateChange) == null || t.call(n, v.Connecting, "livekit:connecting");
89
88
  break;
90
- case k.Connected:
89
+ case b.Connected:
91
90
  i("LiveKit room connected successfully"), w = !0;
92
91
  break;
93
- case k.Disconnected:
94
- i("LiveKit room disconnected"), w = !1, _ = !1, P.publication = null, J.publication = null, (r = n.onConnectionStateChange) == null || r.call(n, v.Disconnected, "livekit:disconnected");
92
+ case b.Disconnected:
93
+ i("LiveKit room disconnected"), w = !1, D = !1, P.publication = null, B.publication = null, (r = n.onConnectionStateChange) == null || r.call(n, v.Disconnected, "livekit:disconnected");
95
94
  break;
96
- case k.Reconnecting:
95
+ case b.Reconnecting:
97
96
  i("LiveKit room reconnecting..."), (o = n.onConnectionStateChange) == null || o.call(n, v.Connecting, "livekit:reconnecting");
98
97
  break;
99
- case k.SignalReconnecting:
98
+ case b.SignalReconnecting:
100
99
  i("LiveKit room signal reconnecting..."), (c = n.onConnectionStateChange) == null || c.call(n, v.Connecting, "livekit:signal-reconnecting");
101
100
  break;
102
101
  }
103
102
  }
104
103
  function Ce(e, t) {
105
104
  var r;
106
- i("Connection quality:", e), t != null && t.isLocal && ((r = n.onConnectivityStateChange) == null || r.call(n, qe[e]));
105
+ i("Connection quality:", e), t != null && t.isLocal && ((r = n.onConnectivityStateChange) == null || r.call(n, We[e]));
107
106
  }
108
107
  function Se(e) {
109
108
  i("Participant connected:", e.identity);
110
109
  }
111
- function Te(e) {
110
+ function ye(e) {
112
111
  i("Participant disconnected:", e.identity), W("livekit:participant-disconnected");
113
112
  }
114
- function ye() {
113
+ function Te() {
115
114
  var e;
116
115
  j !== A.Start && (i("CALLBACK: onVideoStateChange(Start)"), j = A.Start, (e = n.onVideoStateChange) == null || e.call(n, A.Start));
117
116
  }
@@ -127,25 +126,25 @@ async function We(T, L, g) {
127
126
  i(`No mediaStreamTrack available for ${e.kind}`);
128
127
  return;
129
128
  }
130
- R ? (R.addTrack(o), i(`Added ${e.kind} track to shared MediaStream`)) : (R = new MediaStream([o]), i(`Created shared MediaStream with ${e.kind} track`)), e.kind === "audio" && (f = xe(
129
+ R ? (R.addTrack(o), i(`Added ${e.kind} track to shared MediaStream`)) : (R = new MediaStream([o]), i(`Created shared MediaStream with ${e.kind} track`)), e.kind === "audio" && (f = Be(
131
130
  () => e.getRTCStatsReport(),
132
- ({ sttLatency: d, serviceLatency: S }) => {
131
+ ({ sttLatency: d, serviceLatency: y }) => {
133
132
  var oe, ae, ce;
134
- const D = de.get(!0);
135
- let F = 0;
133
+ const F = de.get(!0);
134
+ let N = 0;
136
135
  if (d) {
137
136
  const se = ((ae = (oe = h == null ? void 0 : h.getReport()) == null ? void 0 : oe.webRTCStats) == null ? void 0 : ae.avgRtt) ?? 0;
138
- F = se > 0 ? Math.round(se * 1e3) : 0;
137
+ N = se > 0 ? Math.round(se * 1e3) : 0;
139
138
  }
140
- const V = D > 0 ? D + (d ?? 0) + F : void 0, y = V !== void 0 && S !== void 0 ? V - S : void 0;
141
- (ce = n.onFirstAudioDetected) == null || ce.call(n, { latency: V, networkLatency: y });
139
+ const V = F > 0 ? F + (d ?? 0) + N : void 0, T = V !== void 0 && y !== void 0 ? V - y : void 0;
140
+ (ce = n.onFirstAudioDetected) == null || ce.call(n, { latency: V, networkLatency: T });
142
141
  }
143
- )), e.kind === "video" && ((c = n.onStreamReady) == null || c.call(n), i("CALLBACK: onSrcObjectReady"), (s = n.onSrcObjectReady) == null || s.call(n, R), _ || (_ = !0, i("CALLBACK: onConnectionStateChange(Connected)"), (u = n.onConnectionStateChange) == null || u.call(n, v.Connected, "livekit:track-subscribed")), h = je(
142
+ )), e.kind === "video" && ((c = n.onStreamReady) == null || c.call(n), i("CALLBACK: onSrcObjectReady"), (s = n.onSrcObjectReady) == null || s.call(n, R), D || (D = !0, i("CALLBACK: onConnectionStateChange(Connected)"), (u = n.onConnectionStateChange) == null || u.call(n, v.Connected, "livekit:track-subscribed")), h = Oe(
144
143
  () => e.getRTCStatsReport(),
145
144
  () => w,
146
- Oe,
147
- (d, S) => {
148
- i(`Video state change: ${d}`), d === A.Start ? (E && (clearTimeout(E), E = null, i("Track subscription timeout cleared")), ye()) : d === A.Stop && Z(S);
145
+ Je,
146
+ (d, y) => {
147
+ i(`Video state change: ${d}`), d === A.Start ? (E && (clearTimeout(E), E = null, i("Track subscription timeout cleared")), Te()) : d === A.Stop && Z(y);
149
148
  }
150
149
  ), h.start());
151
150
  }
@@ -154,40 +153,40 @@ async function We(T, L, g) {
154
153
  }
155
154
  function ee(e, t) {
156
155
  var o;
157
- const r = Be[e];
156
+ const r = qe[e];
158
157
  r && ((o = n.onMessage) == null || o.call(n, r, { event: r, ...t }));
159
158
  }
160
- function B(e, t) {
159
+ function J(e, t) {
161
160
  var r, o, c, s, u;
162
- if (e === p.ToolCallStarted) {
161
+ if (e === l.ToolCallStarted) {
163
162
  const d = t;
164
- I = d.interruptible !== !1, (r = n.onInterruptibleChange) == null || r.call(n, I), b = m.ToolActive, (o = n.onAgentActivityStateChange) == null || o.call(n, m.ToolActive), (c = n.onToolEvent) == null || c.call(n, p.ToolCallStarted, d);
163
+ I = d.interruptible !== !1, (r = n.onInterruptibleChange) == null || r.call(n, I), k = m.ToolActive, (o = n.onAgentActivityStateChange) == null || o.call(n, m.ToolActive), (c = n.onToolEvent) == null || c.call(n, l.ToolCallStarted, d);
165
164
  return;
166
165
  }
167
- if (e === p.ToolCallDone) {
168
- (s = n.onToolEvent) == null || s.call(n, p.ToolCallDone, t);
166
+ if (e === l.ToolCallDone) {
167
+ (s = n.onToolEvent) == null || s.call(n, l.ToolCallDone, t);
169
168
  return;
170
169
  }
171
- e === p.ToolCallError && ((u = n.onToolEvent) == null || u.call(n, p.ToolCallError, t));
170
+ e === l.ToolCallError && ((u = n.onToolEvent) == null || u.call(n, l.ToolCallError, t));
172
171
  }
173
172
  function Ee(e, t) {
174
173
  var r, o, c, s, u;
175
- if (I = ((r = t.metadata) == null ? void 0 : r.interruptible) !== !1, (o = n.onInterruptibleChange) == null || o.call(n, I), e === p.StreamVideoCreated) {
176
- b = m.Talking, (c = n.onAgentActivityStateChange) == null || c.call(n, m.Talking), f == null || f.arm({
174
+ if (I = ((r = t.metadata) == null ? void 0 : r.interruptible) !== !1, (o = n.onInterruptibleChange) == null || o.call(n, I), e === l.StreamVideoCreated) {
175
+ k = m.Talking, (c = n.onAgentActivityStateChange) == null || c.call(n, m.Talking), f == null || f.arm({
177
176
  sttLatency: (s = t == null ? void 0 : t.stt) == null ? void 0 : s.latency,
178
177
  serviceLatency: t == null ? void 0 : t.serviceLatency
179
178
  });
180
179
  return;
181
180
  }
182
- I && (b = m.Idle, (u = n.onAgentActivityStateChange) == null || u.call(n, m.Idle));
181
+ I && (k = m.Idle, (u = n.onAgentActivityStateChange) == null || u.call(n, m.Idle));
183
182
  }
184
183
  function x(e, t) {
185
- var s, u, d, S;
184
+ var s, u, d, y;
186
185
  const r = ((u = (s = h == null ? void 0 : h.getReport()) == null ? void 0 : s.webRTCStats) == null ? void 0 : u.avgRtt) ?? 0, o = r > 0 ? Math.round(r / 2 * 1e3) : 0, c = { ...t, downstreamNetworkLatency: o };
187
186
  g.debug && ((d = t == null ? void 0 : t.metadata) != null && d.sentiment) && (c.sentiment = {
188
187
  id: t.metadata.sentiment.id,
189
188
  name: t.metadata.sentiment.sentiment
190
- }), (S = n.onMessage) == null || S.call(n, e, c), Ee(e, t);
189
+ }), (y = n.onMessage) == null || y.call(n, e, c), Ee(e, t);
191
190
  }
192
191
  function Ae(e, t) {
193
192
  var r;
@@ -197,16 +196,16 @@ async function We(T, L, g) {
197
196
  });
198
197
  }
199
198
  const Re = {
200
- [p.ChatAnswer]: ee,
201
- [p.ChatPartial]: ee,
202
- [p.ToolCallStarted]: B,
203
- [p.ToolCallDone]: B,
204
- [p.ToolCallError]: B,
205
- [p.StreamVideoCreated]: x,
206
- [p.StreamVideoDone]: x,
207
- [p.StreamVideoError]: x,
208
- [p.StreamVideoRejected]: x,
209
- [p.ChatAudioTranscribed]: Ae
199
+ [l.ChatAnswer]: ee,
200
+ [l.ChatPartial]: ee,
201
+ [l.ToolCallStarted]: J,
202
+ [l.ToolCallDone]: J,
203
+ [l.ToolCallError]: J,
204
+ [l.StreamVideoCreated]: x,
205
+ [l.StreamVideoDone]: x,
206
+ [l.StreamVideoError]: x,
207
+ [l.StreamVideoRejected]: x,
208
+ [l.ChatAudioTranscribed]: Ae
210
209
  };
211
210
  function Pe(e, t, r, o) {
212
211
  const c = new TextDecoder().decode(e);
@@ -221,16 +220,16 @@ async function We(T, L, g) {
221
220
  }
222
221
  function Le(e) {
223
222
  var t;
224
- i("Media devices error:", e), (t = n.onError) == null || t.call(n, new Error(U), { sessionId: C });
223
+ i("Media devices error:", e), (t = n.onError) == null || t.call(n, _(), { sessionId: S });
225
224
  }
226
225
  function Me(e) {
227
226
  var t;
228
- i("Encryption error:", e), (t = n.onError) == null || t.call(n, new Error(U), { sessionId: C });
227
+ i("Encryption error:", e), (t = n.onError) == null || t.call(n, _(), { sessionId: S });
229
228
  }
230
- function ke(e, t, r) {
229
+ function be(e, t, r) {
231
230
  i("Track subscription failed:", { trackSid: e, participant: t, reason: r });
232
231
  }
233
- function be(e, t, r) {
232
+ function ke(e, t, r) {
234
233
  for (const [o, c] of r)
235
234
  if (c.source === t && c.track) {
236
235
  const s = c.track.mediaStreamTrack;
@@ -240,7 +239,7 @@ async function We(T, L, g) {
240
239
  return null;
241
240
  }
242
241
  async function ne(e, t, r, o, c, s) {
243
- var D, F, V;
242
+ var F, N, V;
244
243
  if (!w || !a)
245
244
  throw i(`Room is not connected, cannot publish ${o} stream`), new Error("Room is not connected");
246
245
  if (e.isPublishing) {
@@ -250,23 +249,23 @@ async function We(T, L, g) {
250
249
  const u = r(t);
251
250
  if (u.length === 0)
252
251
  throw new Error(`No ${o} track found in the provided MediaStream`);
253
- const d = u[0], S = be(d, o, c());
254
- if (S) {
252
+ const d = u[0], y = ke(d, o, c());
253
+ if (y) {
255
254
  i(`${o} track is already published, skipping`, {
256
255
  trackId: d.id,
257
- publishedTrackId: (F = (D = S.track) == null ? void 0 : D.mediaStreamTrack) == null ? void 0 : F.id
258
- }), e.publication = S;
256
+ publishedTrackId: (N = (F = y.track) == null ? void 0 : F.mediaStreamTrack) == null ? void 0 : N.id
257
+ }), e.publication = y;
259
258
  return;
260
259
  }
261
260
  if ((V = e.publication) != null && V.track) {
262
- const y = e.publication.track.mediaStreamTrack;
263
- y !== d && (y == null ? void 0 : y.id) !== d.id && (i(`Unpublishing existing ${o} track before publishing new one`), await s());
261
+ const T = e.publication.track.mediaStreamTrack;
262
+ T !== d && (T == null ? void 0 : T.id) !== d.id && (i(`Unpublishing existing ${o} track before publishing new one`), await s());
264
263
  }
265
264
  i(`Publishing ${o} track from provided MediaStream`, { trackId: d.id }), e.isPublishing = !0;
266
265
  try {
267
266
  e.publication = await a.localParticipant.publishTrack(d, { source: o }), i(`${o} track published successfully`, { trackSid: e.publication.trackSid });
268
- } catch (y) {
269
- throw i(`Failed to publish ${o} track:`, y), y;
267
+ } catch (T) {
268
+ throw i(`Failed to publish ${o} track:`, T), T;
270
269
  } finally {
271
270
  e.isPublishing = !1;
272
271
  }
@@ -312,7 +311,7 @@ async function We(T, L, g) {
312
311
  }
313
312
  async function Ke(e) {
314
313
  return ne(
315
- J,
314
+ B,
316
315
  e,
317
316
  (t) => t.getVideoTracks(),
318
317
  H.Source.Camera,
@@ -321,7 +320,7 @@ async function We(T, L, g) {
321
320
  );
322
321
  }
323
322
  async function q() {
324
- return te(J, "Camera");
323
+ return te(B, "Camera");
325
324
  }
326
325
  function Ve() {
327
326
  R && (R.getTracks().forEach((e) => e.stop()), R = null);
@@ -329,15 +328,15 @@ async function We(T, L, g) {
329
328
  async function z(e, t) {
330
329
  var r, o;
331
330
  if (!w || !a) {
332
- i("Room is not connected for sending messages"), (r = n.onError) == null || r.call(n, new Error(U), {
333
- sessionId: C
331
+ i("Room is not connected for sending messages"), (r = n.onError) == null || r.call(n, _(), {
332
+ sessionId: S
334
333
  });
335
334
  return;
336
335
  }
337
336
  try {
338
337
  await a.localParticipant.sendText(e, { topic: t }), i("Message sent successfully:", e);
339
338
  } catch (c) {
340
- i("Failed to send message:", c), (o = n.onError) == null || o.call(n, new Error(U), { sessionId: C });
339
+ i("Failed to send message:", c), (o = n.onError) == null || o.call(n, _(), { sessionId: S });
341
340
  }
342
341
  }
343
342
  async function ie(e) {
@@ -346,7 +345,7 @@ async function We(T, L, g) {
346
345
  const o = JSON.parse(e).topic;
347
346
  return z("", o);
348
347
  } catch (r) {
349
- i("Failed to send data channel message:", r), (t = n.onError) == null || t.call(n, new Error(U), { sessionId: C });
348
+ i("Failed to send data channel message:", r), (t = n.onError) == null || t.call(n, _(), { sessionId: S });
350
349
  }
351
350
  }
352
351
  function _e(e) {
@@ -358,7 +357,7 @@ async function We(T, L, g) {
358
357
  }
359
358
  async function W(e) {
360
359
  var t, r;
361
- E && (clearTimeout(E), E = null), f == null || f.destroy(), f = null, a && ((t = n.onConnectionStateChange) == null || t.call(n, v.Disconnecting, e), await Promise.all([Q(), q()]), await a.disconnect()), Ve(), w = !1, _ = !1, (r = n.onAgentActivityStateChange) == null || r.call(n, m.Idle), b = m.Idle;
360
+ E && (clearTimeout(E), E = null), f == null || f.destroy(), f = null, a && ((t = n.onConnectionStateChange) == null || t.call(n, v.Disconnecting, e), await Promise.all([Q(), q()]), await a.disconnect()), Ve(), w = !1, D = !1, (r = n.onAgentActivityStateChange) == null || r.call(n, m.Idle), k = m.Idle;
362
361
  }
363
362
  return {
364
363
  speak(e) {
@@ -372,22 +371,22 @@ async function We(T, L, g) {
372
371
  disconnect: () => W("user:disconnect"),
373
372
  async reconnect() {
374
373
  var e, t;
375
- if ((a == null ? void 0 : a.state) === k.Connected) {
374
+ if ((a == null ? void 0 : a.state) === b.Connected) {
376
375
  i("Room is already connected");
377
376
  return;
378
377
  }
379
378
  if (!a || !K || !$)
380
379
  throw i("Cannot reconnect: missing room, URL or token"), new Error("Cannot reconnect: session not available");
381
- i("Reconnecting to LiveKit room, state:", a.state), _ = !1, (e = n.onConnectionStateChange) == null || e.call(n, v.Connecting, "user:reconnect");
380
+ i("Reconnecting to LiveKit room, state:", a.state), D = !1, (e = n.onConnectionStateChange) == null || e.call(n, v.Connecting, "user:reconnect");
382
381
  try {
383
382
  if (await a.connect(K, $), i("Room reconnected"), w = !0, a.remoteParticipants.size === 0) {
384
383
  if (i("Waiting for agent to join..."), !await new Promise((o) => {
385
384
  const c = setTimeout(() => {
386
- a == null || a.off(l.ParticipantConnected, s), o(!1);
385
+ a == null || a.off(p.ParticipantConnected, s), o(!1);
387
386
  }, 5e3), s = () => {
388
- clearTimeout(c), a == null || a.off(l.ParticipantConnected, s), o(!0);
387
+ clearTimeout(c), a == null || a.off(p.ParticipantConnected, s), o(!0);
389
388
  };
390
- a == null || a.on(l.ParticipantConnected, s);
389
+ a == null || a.on(p.ParticipantConnected, s);
391
390
  }))
392
391
  throw i("Agent did not join within timeout"), await a.disconnect(), new Error("Agent did not rejoin the room");
393
392
  i("Agent joined, reconnection successful");
@@ -415,14 +414,14 @@ async function We(T, L, g) {
415
414
  unregisterRpcMethod(e) {
416
415
  a == null || a.unregisterRpcMethod(e);
417
416
  },
418
- sessionId: C,
419
- streamId: C,
417
+ sessionId: S,
418
+ streamId: S,
420
419
  streamType: X,
421
420
  interruptAvailable: Y,
422
421
  isInterruptible: I
423
422
  };
424
423
  }
425
424
  export {
426
- We as createLiveKitStreamingManager,
427
- pe as handleInitError
425
+ Ge as createLiveKitStreamingManager,
426
+ le as handleInitError
428
427
  };
@@ -1,12 +1,13 @@
1
- interface BaseErrorParams {
1
+ export interface ErrorJson {
2
2
  kind: string;
3
- description?: string;
4
- error?: Error;
3
+ message: string;
4
+ cause?: string;
5
+ [key: string]: any;
5
6
  }
6
7
  export declare class BaseError extends Error {
7
- kind: string;
8
- description?: string;
9
- error?: Error;
10
- constructor({ kind, description, error }: BaseErrorParams);
8
+ readonly kind: string;
9
+ readonly originalError?: unknown | undefined;
10
+ constructor(message: string, kind?: string, originalError?: unknown | undefined);
11
+ toJson(): ErrorJson;
11
12
  }
12
- export {};
13
+ export declare function isDIDError(error: unknown): error is BaseError;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ import { BaseError, ErrorJson } from './base-error';
2
+
3
+ export declare class HttpError extends BaseError {
4
+ readonly status: number;
5
+ readonly url?: string;
6
+ readonly method?: string;
7
+ constructor(status: number, body: string, meta?: {
8
+ url?: string;
9
+ method?: string;
10
+ });
11
+ toJson(): ErrorJson;
12
+ }
@@ -1,4 +1,8 @@
1
+ export * from './base-error';
1
2
  export * from './chat/chat-creation-failed';
2
3
  export * from './chat/chat-mode-downgraded';
4
+ export * from './http-error';
5
+ export * from './network-error';
6
+ export * from './stream-error';
3
7
  export * from './validation-error';
4
8
  export * from './ws-error';
@@ -0,0 +1,5 @@
1
+ import { BaseError } from './base-error';
2
+
3
+ export declare class NetworkError extends BaseError {
4
+ constructor(originalError?: unknown);
5
+ }
@@ -0,0 +1,5 @@
1
+ import { BaseError } from './base-error';
2
+
3
+ export declare class StreamError extends BaseError {
4
+ constructor(message: string, originalError?: unknown);
5
+ }
@@ -1,6 +1,6 @@
1
1
  import { BaseError } from './base-error';
2
2
 
3
3
  export declare class ValidationError extends BaseError {
4
- key?: string;
5
- constructor(message: string, key?: string);
4
+ readonly key?: string | undefined;
5
+ constructor(message: string, key?: string | undefined);
6
6
  }
@@ -1,7 +1,9 @@
1
1
  import { Agent, AgentsAPI, Chat, ChatMode } from '../../types';
2
2
  import { Analytics } from '../analytics/mixpanel';
3
3
 
4
- export declare function getRequestHeaders(chatMode?: ChatMode): Record<string, Record<string, string>>;
4
+ export declare function getRequestHeaders(chatMode?: ChatMode): {
5
+ headers?: Record<string, string>;
6
+ };
5
7
  export declare function createChat(agent: Agent, agentsApi: AgentsAPI, analytics: Analytics, chatMode?: ChatMode, persist?: boolean, chat?: Chat): Promise<{
6
8
  chat: Chat | undefined;
7
9
  chatMode: ChatMode | undefined;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import { ErrorJson } from '../errors';
2
+
3
+ export type ErrorAnalyticsProps = ErrorJson;
4
+ export declare function toErrorAnalytics(error: unknown): ErrorAnalyticsProps;
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@d-id/client-sdk",
3
3
  "private": false,
4
- "version": "1.1.71",
4
+ "version": "1.2.0-staging.339",
5
5
  "type": "module",
6
6
  "description": "d-id client sdk",
7
7
  "repository": {