@d-id/client-sdk 1.1.71 → 1.2.1-staging.341
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{index-OAVAtXjd.js → index-vpTphBDp.js} +703 -656
- package/dist/index.js +31 -26
- package/dist/index.umd.cjs +5 -5
- package/dist/{livekit-manager-B01_ssBG.js → livekit-manager-CFuAnjAa.js} +109 -110
- package/dist/src/errors/base-error.d.ts +9 -8
- package/dist/src/errors/errors.test.d.ts +1 -0
- package/dist/src/errors/http-error.d.ts +12 -0
- package/dist/src/errors/index.d.ts +4 -0
- package/dist/src/errors/network-error.d.ts +11 -0
- package/dist/src/errors/stream-error.d.ts +5 -0
- package/dist/src/errors/validation-error.d.ts +2 -2
- package/dist/src/services/chat/index.d.ts +3 -1
- package/dist/src/services/chat/index.test.d.ts +1 -0
- package/dist/src/utils/error-analytics.d.ts +4 -0
- package/dist/src/utils/error-analytics.test.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { c as De, C as O, S as
|
|
2
|
-
function
|
|
3
|
-
const M = De(
|
|
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-vpTphBDp.js";
|
|
2
|
+
function Qe(C, L, g, i) {
|
|
3
|
+
const M = De(C, `${L}/v2/agents/${g}`, i);
|
|
4
4
|
return {
|
|
5
|
-
async createStream(
|
|
6
|
-
return M.post("/sessions",
|
|
5
|
+
async createStream(p) {
|
|
6
|
+
return M.post("/sessions", p);
|
|
7
7
|
}
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
-
const
|
|
11
|
-
[
|
|
12
|
-
[
|
|
10
|
+
const qe = {
|
|
11
|
+
[l.ChatAnswer]: O.Answer,
|
|
12
|
+
[l.ChatPartial]: O.Partial
|
|
13
13
|
}, ue = 2e4;
|
|
14
|
-
async function
|
|
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
|
|
24
|
-
excellent:
|
|
25
|
-
good:
|
|
26
|
-
poor:
|
|
27
|
-
lost:
|
|
28
|
-
unknown:
|
|
29
|
-
},
|
|
30
|
-
|
|
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:",
|
|
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
|
|
34
|
+
async function Ge(C, L, g) {
|
|
38
35
|
var re;
|
|
39
|
-
const i = Fe(g.debug || !1, "LiveKitStreamingManager"), { Room: M, RoomEvent:
|
|
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 },
|
|
44
|
-
let h = null, f = null, j = null,
|
|
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,
|
|
51
|
-
const ge =
|
|
52
|
-
let
|
|
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:
|
|
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
|
-
|
|
57
|
+
le(e, i, n);
|
|
61
58
|
}
|
|
62
|
-
if (!K || !$ || !
|
|
59
|
+
if (!K || !$ || !S)
|
|
63
60
|
return Promise.reject(new Error("Failed to initialize LiveKit stream"));
|
|
64
|
-
a.on(
|
|
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(),
|
|
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
|
|
67
|
+
var t;
|
|
71
68
|
i(
|
|
72
69
|
`Track subscription timeout - no track subscribed within ${ue / 1e3} seconds after connect`
|
|
73
|
-
), E = null
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
89
|
+
case b.Connected:
|
|
91
90
|
i("LiveKit room connected successfully"), w = !0;
|
|
92
91
|
break;
|
|
93
|
-
case
|
|
94
|
-
i("LiveKit room disconnected"), w = !1,
|
|
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
|
|
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
|
|
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,
|
|
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
|
|
110
|
+
function ye(e) {
|
|
112
111
|
i("Participant disconnected:", e.identity), W("livekit:participant-disconnected");
|
|
113
112
|
}
|
|
114
|
-
function
|
|
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 =
|
|
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:
|
|
131
|
+
({ sttLatency: d, serviceLatency: y }) => {
|
|
133
132
|
var oe, ae, ce;
|
|
134
|
-
const
|
|
135
|
-
let
|
|
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
|
-
|
|
137
|
+
N = se > 0 ? Math.round(se * 1e3) : 0;
|
|
139
138
|
}
|
|
140
|
-
const V =
|
|
141
|
-
(ce = n.onFirstAudioDetected) == null || ce.call(n, { latency: V, networkLatency:
|
|
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),
|
|
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
|
-
|
|
147
|
-
(d,
|
|
148
|
-
i(`Video state change: ${d}`), d === A.Start ? (E && (clearTimeout(E), E = null, i("Track subscription timeout cleared")),
|
|
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 =
|
|
156
|
+
const r = qe[e];
|
|
158
157
|
r && ((o = n.onMessage) == null || o.call(n, r, { event: r, ...t }));
|
|
159
158
|
}
|
|
160
|
-
function
|
|
159
|
+
function J(e, t) {
|
|
161
160
|
var r, o, c, s, u;
|
|
162
|
-
if (e ===
|
|
161
|
+
if (e === l.ToolCallStarted) {
|
|
163
162
|
const d = t;
|
|
164
|
-
I = d.interruptible !== !1, (r = n.onInterruptibleChange) == null || r.call(n, I),
|
|
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 ===
|
|
168
|
-
(s = n.onToolEvent) == null || s.call(n,
|
|
166
|
+
if (e === l.ToolCallDone) {
|
|
167
|
+
(s = n.onToolEvent) == null || s.call(n, l.ToolCallDone, t);
|
|
169
168
|
return;
|
|
170
169
|
}
|
|
171
|
-
e ===
|
|
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 ===
|
|
176
|
-
|
|
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 && (
|
|
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,
|
|
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
|
-
}), (
|
|
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
|
-
[
|
|
201
|
-
[
|
|
202
|
-
[
|
|
203
|
-
[
|
|
204
|
-
[
|
|
205
|
-
[
|
|
206
|
-
[
|
|
207
|
-
[
|
|
208
|
-
[
|
|
209
|
-
[
|
|
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,
|
|
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,
|
|
227
|
+
i("Encryption error:", e), (t = n.onError) == null || t.call(n, _(), { sessionId: S });
|
|
229
228
|
}
|
|
230
|
-
function
|
|
229
|
+
function be(e, t, r) {
|
|
231
230
|
i("Track subscription failed:", { trackSid: e, participant: t, reason: r });
|
|
232
231
|
}
|
|
233
|
-
function
|
|
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
|
|
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],
|
|
254
|
-
if (
|
|
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: (
|
|
258
|
-
}), e.publication =
|
|
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
|
|
263
|
-
|
|
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 (
|
|
269
|
-
throw i(`Failed to publish ${o} track:`,
|
|
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
|
-
|
|
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(
|
|
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,
|
|
333
|
-
sessionId:
|
|
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,
|
|
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,
|
|
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,
|
|
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) ===
|
|
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),
|
|
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(
|
|
385
|
+
a == null || a.off(p.ParticipantConnected, s), o(!1);
|
|
387
386
|
}, 5e3), s = () => {
|
|
388
|
-
clearTimeout(c), a == null || a.off(
|
|
387
|
+
clearTimeout(c), a == null || a.off(p.ParticipantConnected, s), o(!0);
|
|
389
388
|
};
|
|
390
|
-
a == null || a.on(
|
|
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:
|
|
419
|
-
streamId:
|
|
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
|
-
|
|
427
|
-
|
|
425
|
+
Ge as createLiveKitStreamingManager,
|
|
426
|
+
le as handleInitError
|
|
428
427
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
interface
|
|
1
|
+
export interface ErrorJson {
|
|
2
2
|
kind: string;
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
message: string;
|
|
4
|
+
cause?: string;
|
|
5
|
+
[key: string]: any;
|
|
5
6
|
}
|
|
6
7
|
export declare class BaseError extends Error {
|
|
7
|
-
kind: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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,11 @@
|
|
|
1
|
+
import { BaseError, ErrorJson } from './base-error';
|
|
2
|
+
|
|
3
|
+
export declare class NetworkError extends BaseError {
|
|
4
|
+
readonly endpoint?: string;
|
|
5
|
+
readonly method?: string;
|
|
6
|
+
constructor(originalError?: unknown, meta?: {
|
|
7
|
+
url?: string;
|
|
8
|
+
method?: string;
|
|
9
|
+
});
|
|
10
|
+
toJson(): ErrorJson;
|
|
11
|
+
}
|
|
@@ -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):
|
|
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 @@
|
|
|
1
|
+
export {};
|