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