@d-id/client-sdk 1.1.20-staging.90 → 1.1.20
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-BH8ByqOr.js → index-DcoRNuxp.js} +248 -249
- package/dist/index.js +1 -1
- package/dist/index.umd.cjs +5 -5
- package/dist/{livekit-manager-D9xuX-OS.js → livekit-manager-CNKaXUpT.js} +68 -62
- package/dist/src/api/streams/streamsApiV2.d.ts +2 -2
- package/dist/src/services/agent-manager/connect-to-manager.d.ts +2 -2
- package/dist/src/services/streaming-manager/common.d.ts +2 -2
- package/dist/src/services/streaming-manager/factory.d.ts +3 -3
- package/dist/src/services/streaming-manager/livekit-manager.d.ts +2 -2
- package/dist/src/types/stream/streams-v2.d.ts +7 -6
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { c as H, a as X, S as Y, d as Z, T as
|
|
2
|
-
function
|
|
3
|
-
const
|
|
1
|
+
import { c as H, a as X, S as Y, d as Z, T as k, C as u, b as p, A as K, e as F, f as b, g as ee } from "./index-DcoRNuxp.js";
|
|
2
|
+
function ne(c, f, s, i) {
|
|
3
|
+
const h = H(c, `${f}/v2/agents/${s}`, i);
|
|
4
4
|
return {
|
|
5
5
|
async createStream(a) {
|
|
6
|
-
return
|
|
6
|
+
return h.post("/streams", a);
|
|
7
7
|
}
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
-
async function
|
|
10
|
+
async function te() {
|
|
11
11
|
try {
|
|
12
12
|
return await import("./livekit-client.esm-C1GRQdZY.js");
|
|
13
13
|
} catch {
|
|
@@ -16,7 +16,7 @@ async function ne() {
|
|
|
16
16
|
);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
const
|
|
19
|
+
const ie = {
|
|
20
20
|
excellent: p.Strong,
|
|
21
21
|
good: p.Strong,
|
|
22
22
|
poor: p.Weak,
|
|
@@ -26,49 +26,55 @@ const te = {
|
|
|
26
26
|
kind: "InternalServerError",
|
|
27
27
|
description: "Stream Error"
|
|
28
28
|
});
|
|
29
|
-
function
|
|
30
|
-
var
|
|
31
|
-
throw f("Failed to connect to LiveKit room:", c), i(), (
|
|
29
|
+
function _(c, f, s, i) {
|
|
30
|
+
var h, a;
|
|
31
|
+
throw f("Failed to connect to LiveKit room:", c), i(), (h = s.onConnectionStateChange) == null || h.call(s, u.Fail), (a = s.onError) == null || a.call(s, c, { streamId: "" }), c;
|
|
32
32
|
}
|
|
33
|
-
async function
|
|
34
|
-
var
|
|
35
|
-
const i = X(s.debug || !1, "LiveKitStreamingManager"), {
|
|
33
|
+
async function se(c, f, s) {
|
|
34
|
+
var D, P;
|
|
35
|
+
const i = X(s.debug || !1, "LiveKitStreamingManager"), {
|
|
36
|
+
Room: h,
|
|
37
|
+
RoomEvent: a,
|
|
38
|
+
ConnectionState: v,
|
|
39
|
+
RemoteParticipant: oe,
|
|
40
|
+
RemoteTrack: re
|
|
41
|
+
} = await te(), { callbacks: e, auth: I, baseURL: N, analytics: U } = s;
|
|
36
42
|
let g = null, y = !1;
|
|
37
|
-
const
|
|
38
|
-
let w = !0,
|
|
39
|
-
g = new
|
|
43
|
+
const R = Y.Fluent;
|
|
44
|
+
let w = !0, C = null;
|
|
45
|
+
g = new h({
|
|
40
46
|
adaptiveStream: !1,
|
|
41
47
|
// Must be false to use mediaStreamTrack directly
|
|
42
48
|
dynacast: !0
|
|
43
49
|
});
|
|
44
|
-
const
|
|
45
|
-
let
|
|
50
|
+
const x = ne(I, N || Z, c, e.onError);
|
|
51
|
+
let m, L, E, T;
|
|
46
52
|
try {
|
|
47
|
-
const n = await
|
|
48
|
-
transport_provider:
|
|
49
|
-
|
|
50
|
-
}), {
|
|
51
|
-
(
|
|
53
|
+
const n = await x.createStream({
|
|
54
|
+
transport_provider: k.Livekit,
|
|
55
|
+
chat_id: f.chat_id
|
|
56
|
+
}), { session_id: t, session_token: o, session_url: r } = n;
|
|
57
|
+
(D = e.onStreamCreated) == null || D.call(e, { stream_id: t, session_id: t, agent_id: c }), m = t, L = t, E = o, T = r, await g.prepareConnection(T, E);
|
|
52
58
|
} catch (n) {
|
|
53
|
-
|
|
59
|
+
_(n, i, e, () => {
|
|
54
60
|
w = !1;
|
|
55
61
|
});
|
|
56
62
|
}
|
|
57
|
-
if (!T || !E || !
|
|
63
|
+
if (!T || !E || !m || !L)
|
|
58
64
|
return Promise.reject(new Error("Failed to initialize LiveKit stream"));
|
|
59
|
-
g.on(a.ConnectionStateChanged,
|
|
65
|
+
g.on(a.ConnectionStateChanged, j).on(a.ConnectionQualityChanged, O).on(a.ActiveSpeakersChanged, J).on(a.ParticipantConnected, Q).on(a.TrackSubscribed, V).on(a.TrackUnsubscribed, q).on(a.DataReceived, z).on(a.MediaDevicesError, W).on(a.EncryptionError, l).on(a.TrackSubscriptionFailed, B), (P = e.onConnectionStateChange) == null || P.call(e, u.New);
|
|
60
66
|
try {
|
|
61
67
|
await g.connect(T, E), i("LiveKit room joined successfully"), w = !1;
|
|
62
68
|
} catch (n) {
|
|
63
|
-
|
|
69
|
+
_(n, i, e, () => {
|
|
64
70
|
w = !1;
|
|
65
71
|
});
|
|
66
72
|
}
|
|
67
|
-
|
|
68
|
-
"stream-type":
|
|
73
|
+
U.enrich({
|
|
74
|
+
"stream-type": R
|
|
69
75
|
});
|
|
70
|
-
function
|
|
71
|
-
var t, o, r, d,
|
|
76
|
+
function j(n) {
|
|
77
|
+
var t, o, r, d, S;
|
|
72
78
|
switch (i("Connection state changed:", n), n) {
|
|
73
79
|
case v.Connecting:
|
|
74
80
|
(t = e.onConnectionStateChange) == null || t.call(e, u.Connecting);
|
|
@@ -86,45 +92,45 @@ async function oe(c, f, s) {
|
|
|
86
92
|
i("LiveKit room reconnecting..."), (d = e.onConnectionStateChange) == null || d.call(e, u.Connecting);
|
|
87
93
|
break;
|
|
88
94
|
case v.SignalReconnecting:
|
|
89
|
-
i("LiveKit room signal reconnecting..."), (
|
|
95
|
+
i("LiveKit room signal reconnecting..."), (S = e.onConnectionStateChange) == null || S.call(e, u.Connecting);
|
|
90
96
|
break;
|
|
91
97
|
}
|
|
92
98
|
}
|
|
93
|
-
function
|
|
99
|
+
function O(n, t) {
|
|
94
100
|
var o;
|
|
95
|
-
i("Connection quality:", n), t != null && t.isLocal && ((o = e.onConnectivityStateChange) == null || o.call(e,
|
|
101
|
+
i("Connection quality:", n), t != null && t.isLocal && ((o = e.onConnectivityStateChange) == null || o.call(e, ie[n]));
|
|
96
102
|
}
|
|
97
|
-
function
|
|
103
|
+
function J(n) {
|
|
98
104
|
var o, r;
|
|
99
|
-
i("Active speakers changed:", n), n[0] ? (o = e.onAgentActivityStateChange) == null || o.call(e,
|
|
105
|
+
i("Active speakers changed:", n), n[0] ? (o = e.onAgentActivityStateChange) == null || o.call(e, K.Talking) : (r = e.onAgentActivityStateChange) == null || r.call(e, K.Idle);
|
|
100
106
|
}
|
|
101
|
-
function
|
|
107
|
+
function Q(n) {
|
|
102
108
|
i("Participant connected:", n.identity);
|
|
103
109
|
}
|
|
104
|
-
function
|
|
105
|
-
var d,
|
|
110
|
+
function V(n, t, o) {
|
|
111
|
+
var d, S;
|
|
106
112
|
i(`Track subscribed: ${n.kind} from ${o.identity}`);
|
|
107
113
|
const r = n.mediaStreamTrack;
|
|
108
114
|
if (!r) {
|
|
109
115
|
i(`No mediaStreamTrack available for ${n.kind}`);
|
|
110
116
|
return;
|
|
111
117
|
}
|
|
112
|
-
|
|
118
|
+
C ? (C.addTrack(r), i(`Added ${n.kind} track to shared MediaStream`)) : (C = new MediaStream([r]), i(`Created shared MediaStream with ${n.kind} track`)), n.kind === "video" && ((d = e.onSrcObjectReady) == null || d.call(e, C), (S = e.onVideoStateChange) == null || S.call(e, F.Start));
|
|
113
119
|
}
|
|
114
|
-
function
|
|
120
|
+
function q(n, t, o) {
|
|
115
121
|
var r;
|
|
116
122
|
i(`Track unsubscribed: ${n.kind} from ${o.identity}`), n.kind === "video" && ((r = e.onVideoStateChange) == null || r.call(e, F.Stop));
|
|
117
123
|
}
|
|
118
|
-
function
|
|
124
|
+
function z(n, t) {
|
|
119
125
|
var r;
|
|
120
126
|
const o = new TextDecoder().decode(n);
|
|
121
127
|
i("Data received:", o);
|
|
122
128
|
try {
|
|
123
129
|
const d = JSON.parse(o);
|
|
124
|
-
if (d.subject ===
|
|
125
|
-
const
|
|
126
|
-
(r = e.onMessage) == null || r.call(e,
|
|
127
|
-
event:
|
|
130
|
+
if (d.subject === b.ChatAnswer) {
|
|
131
|
+
const S = ee.Answer;
|
|
132
|
+
(r = e.onMessage) == null || r.call(e, S, {
|
|
133
|
+
event: S,
|
|
128
134
|
...d
|
|
129
135
|
});
|
|
130
136
|
}
|
|
@@ -132,25 +138,25 @@ async function oe(c, f, s) {
|
|
|
132
138
|
i("Failed to parse data channel message:", d);
|
|
133
139
|
}
|
|
134
140
|
}
|
|
135
|
-
function
|
|
141
|
+
function W(n) {
|
|
136
142
|
var t;
|
|
137
|
-
i("Media devices error:", n), (t = e.onError) == null || t.call(e, new Error(A), {
|
|
143
|
+
i("Media devices error:", n), (t = e.onError) == null || t.call(e, new Error(A), { streamId: m });
|
|
138
144
|
}
|
|
139
|
-
function
|
|
145
|
+
function l(n) {
|
|
140
146
|
var t;
|
|
141
|
-
i("Encryption error:", n), (t = e.onError) == null || t.call(e, new Error(A), {
|
|
147
|
+
i("Encryption error:", n), (t = e.onError) == null || t.call(e, new Error(A), { streamId: m });
|
|
142
148
|
}
|
|
143
149
|
function B(n, t, o) {
|
|
144
150
|
i("Track subscription failed:", { trackSid: n, participant: t, reason: o });
|
|
145
151
|
}
|
|
146
152
|
function G() {
|
|
147
|
-
|
|
153
|
+
C && (C.getTracks().forEach((n) => n.stop()), C = null);
|
|
148
154
|
}
|
|
149
|
-
async function
|
|
155
|
+
async function M(n) {
|
|
150
156
|
var t, o;
|
|
151
157
|
if (!y || !g) {
|
|
152
158
|
i("Room is not connected for sending messages"), (t = e.onError) == null || t.call(e, new Error(A), {
|
|
153
|
-
|
|
159
|
+
streamId: m
|
|
154
160
|
});
|
|
155
161
|
return;
|
|
156
162
|
}
|
|
@@ -159,7 +165,7 @@ async function oe(c, f, s) {
|
|
|
159
165
|
topic: "lk.chat"
|
|
160
166
|
}), i("Message sent successfully:", n);
|
|
161
167
|
} catch (r) {
|
|
162
|
-
i("Failed to send message:", r), (o = e.onError) == null || o.call(e, new Error(A), {
|
|
168
|
+
i("Failed to send message:", r), (o = e.onError) == null || o.call(e, new Error(A), { streamId: m });
|
|
163
169
|
}
|
|
164
170
|
}
|
|
165
171
|
return {
|
|
@@ -168,22 +174,22 @@ async function oe(c, f, s) {
|
|
|
168
174
|
type: "speak",
|
|
169
175
|
payload: n
|
|
170
176
|
});
|
|
171
|
-
return
|
|
177
|
+
return M(t);
|
|
172
178
|
},
|
|
173
179
|
async disconnect() {
|
|
174
180
|
var n, t;
|
|
175
|
-
g && (await g.disconnect(), g = null), G(), y = !1, (n = e.onConnectionStateChange) == null || n.call(e, u.Completed), (t = e.onAgentActivityStateChange) == null || t.call(e,
|
|
181
|
+
g && (await g.disconnect(), g = null), G(), y = !1, (n = e.onConnectionStateChange) == null || n.call(e, u.Completed), (t = e.onAgentActivityStateChange) == null || t.call(e, K.Idle);
|
|
176
182
|
},
|
|
177
|
-
sendDataChannelMessage:
|
|
178
|
-
sendTextMessage:
|
|
179
|
-
sessionId:
|
|
180
|
-
streamId:
|
|
181
|
-
streamType:
|
|
183
|
+
sendDataChannelMessage: M,
|
|
184
|
+
sendTextMessage: M,
|
|
185
|
+
sessionId: L,
|
|
186
|
+
streamId: m,
|
|
187
|
+
streamType: R,
|
|
182
188
|
interruptAvailable: !0,
|
|
183
189
|
triggersAvailable: !1
|
|
184
190
|
};
|
|
185
191
|
}
|
|
186
192
|
export {
|
|
187
|
-
|
|
188
|
-
|
|
193
|
+
se as createLiveKitStreamingManager,
|
|
194
|
+
_ as handleInitError
|
|
189
195
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Auth,
|
|
1
|
+
import { Auth, CreateStreamV2Options, CreateStreamV2Response } from '../../types';
|
|
2
2
|
|
|
3
3
|
export declare function createStreamApiV2(auth: Auth, host: string, agentId: string, onError?: (error: Error, errorData: object) => void): {
|
|
4
|
-
createStream(options:
|
|
4
|
+
createStream(options: CreateStreamV2Options): Promise<CreateStreamV2Response>;
|
|
5
5
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StreamingManager } from '../streaming-manager';
|
|
2
|
-
import { Agent, AgentManagerOptions, AgentsAPI, Chat, ChatProgressCallback,
|
|
2
|
+
import { Agent, AgentManagerOptions, AgentsAPI, Chat, ChatProgressCallback, CreateStreamOptions, CreateStreamV2Options } from '../../types';
|
|
3
3
|
import { Analytics } from '../analytics/mixpanel';
|
|
4
4
|
|
|
5
5
|
type ConnectToManagerOptions = AgentManagerOptions & {
|
|
@@ -12,6 +12,6 @@ type ConnectToManagerOptions = AgentManagerOptions & {
|
|
|
12
12
|
};
|
|
13
13
|
export declare function initializeStreamAndChat(agent: Agent, options: ConnectToManagerOptions, agentsApi: AgentsAPI, analytics: Analytics, chat?: Chat): Promise<{
|
|
14
14
|
chat?: Chat;
|
|
15
|
-
streamingManager?: StreamingManager<CreateStreamOptions |
|
|
15
|
+
streamingManager?: StreamingManager<CreateStreamOptions | CreateStreamV2Options>;
|
|
16
16
|
}>;
|
|
17
17
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CreateStreamOptions, CreateStreamV2Options, PayloadType, StreamType } from '../../types';
|
|
2
2
|
|
|
3
3
|
export declare const createStreamingLogger: (debug: boolean, prefix: string) => (message: string, extra?: any) => false | void;
|
|
4
4
|
/**
|
|
5
5
|
* Shared type for all streaming managers (LiveKit, WebRTC, etc.)
|
|
6
6
|
* This type represents the return value of any streaming manager implementation
|
|
7
7
|
*/
|
|
8
|
-
export type StreamingManager<T extends CreateStreamOptions |
|
|
8
|
+
export type StreamingManager<T extends CreateStreamOptions | CreateStreamV2Options> = {
|
|
9
9
|
/**
|
|
10
10
|
* Method to send request to server to get clip or talk depending on payload
|
|
11
11
|
* @param payload The payload to send to the streaming service
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Agent,
|
|
1
|
+
import { Agent, CreateStreamOptions, CreateStreamV2Options, StreamingManagerOptions } from '../../types';
|
|
2
2
|
import { StreamingManager } from './common';
|
|
3
3
|
|
|
4
4
|
export declare enum StreamApiVersion {
|
|
@@ -9,5 +9,5 @@ export type ExtendedStreamOptions = ({
|
|
|
9
9
|
version: StreamApiVersion.V1;
|
|
10
10
|
} & CreateStreamOptions) | ({
|
|
11
11
|
version: StreamApiVersion.V2;
|
|
12
|
-
} &
|
|
13
|
-
export declare function createStreamingManager(agent: Agent, streamOptions: ExtendedStreamOptions, options: StreamingManagerOptions): Promise<StreamingManager<CreateStreamOptions |
|
|
12
|
+
} & CreateStreamV2Options);
|
|
13
|
+
export declare function createStreamingManager(agent: Agent, streamOptions: ExtendedStreamOptions, options: StreamingManagerOptions): Promise<StreamingManager<CreateStreamOptions | CreateStreamV2Options>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CreateStreamOptions, CreateStreamV2Options, StreamingManagerOptions } from '../../types';
|
|
2
2
|
import { StreamingManager } from './common';
|
|
3
3
|
|
|
4
4
|
export declare function handleInitError(error: unknown, log: (message?: any, ...optionalParams: any[]) => void, callbacks: StreamingManagerOptions['callbacks'], markInitialConnectionDone: () => void): void;
|
|
5
|
-
export declare function createLiveKitStreamingManager<T extends
|
|
5
|
+
export declare function createLiveKitStreamingManager<T extends CreateStreamV2Options>(agentId: string, agent: T, options: StreamingManagerOptions): Promise<StreamingManager<T>>;
|
|
6
6
|
export type LiveKitStreamingManager<T extends CreateStreamOptions> = StreamingManager<T>;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
export declare enum TransportProvider {
|
|
2
2
|
Livekit = "livekit"
|
|
3
3
|
}
|
|
4
|
-
export interface
|
|
4
|
+
export interface CreateStreamV2Options {
|
|
5
5
|
transport_provider: TransportProvider.Livekit;
|
|
6
|
-
|
|
6
|
+
chat_id?: string;
|
|
7
7
|
}
|
|
8
|
-
export interface
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
export interface CreateStreamV2Response {
|
|
9
|
+
agent_id: 'string';
|
|
10
|
+
session_id: 'string';
|
|
11
|
+
session_url: 'string';
|
|
12
|
+
session_token: 'string';
|
|
12
13
|
}
|