@d-id/client-sdk 1.1.14 → 1.1.15
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-DC-HTOF-.js +1337 -0
- package/dist/index.js +27 -1275
- package/dist/index.umd.cjs +38 -1
- package/dist/livekit-client.esm-C1GRQdZY.js +16663 -0
- package/dist/livekit-manager-tsiAM1XU.js +124 -0
- package/dist/src/services/agent-manager/connect-to-manager.d.ts +3 -2
- package/dist/src/services/streaming-manager/common.d.ts +2 -2
- package/dist/src/services/streaming-manager/factory.d.ts +12 -2
- package/dist/src/services/streaming-manager/index.d.ts +3 -1
- package/dist/src/services/streaming-manager/livekit-manager.d.ts +2 -2
- package/dist/src/types/stream/stream.d.ts +6 -0
- package/dist/src/types/stream/streams-v2.d.ts +3 -2
- package/dist/src/utils/agent.d.ts +1 -0
- package/package.json +1 -1
- package/dist/src/services/agent-manager/connect-to-manager.test.d.ts +0 -1
- package/dist/src/services/agent-manager/index.test.d.ts +0 -1
- package/dist/src/services/streaming-manager/advanced.test.d.ts +0 -5
- package/dist/src/services/streaming-manager/business-flows.test.d.ts +0 -5
- package/dist/src/services/streaming-manager/disconnect.test.d.ts +0 -5
- package/dist/src/services/streaming-manager/edge-cases.test.d.ts +0 -5
- package/dist/src/services/streaming-manager/factory.test.d.ts +0 -1
- package/dist/src/services/streaming-manager/webrtc-core.test.d.ts +0 -5
- package/dist/src/services/streaming-manager/webrtc-utils.test.d.ts +0 -5
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { c as x, a as N, S as O, C as g, b as U, d as P, e as $, A as T, f as q, T as J } from "./index-DC-HTOF-.js";
|
|
2
|
+
function Q(u, p, h, i) {
|
|
3
|
+
const w = x(u, `${p}/v2/agents/${h}`, i);
|
|
4
|
+
return {
|
|
5
|
+
async createStream(d) {
|
|
6
|
+
return w.post("/streams", d);
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
async function W() {
|
|
11
|
+
try {
|
|
12
|
+
return await import("./livekit-client.esm-C1GRQdZY.js");
|
|
13
|
+
} catch {
|
|
14
|
+
throw new Error(
|
|
15
|
+
"LiveKit client is required for this streaming manager. Please install it using: npm install livekit-client"
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
async function H(u, p, h) {
|
|
20
|
+
var E, K, I;
|
|
21
|
+
const i = N(h.debug || !1, "LiveKitStreamingManager"), {
|
|
22
|
+
Room: w,
|
|
23
|
+
RoomEvent: d,
|
|
24
|
+
ConnectionState: C,
|
|
25
|
+
RemoteParticipant: z,
|
|
26
|
+
RemoteTrack: B
|
|
27
|
+
} = await W(), { callbacks: e, auth: V, baseURL: j, analytics: F } = h;
|
|
28
|
+
let a = null, v = !1, y = null, c = null;
|
|
29
|
+
const L = O.Fluent;
|
|
30
|
+
a = new w({
|
|
31
|
+
adaptiveStream: !0,
|
|
32
|
+
dynacast: !0
|
|
33
|
+
}), a.on(d.ConnectionStateChanged, (n) => {
|
|
34
|
+
var t, o, r, s, S;
|
|
35
|
+
switch (i("Connection state changed:", n), n) {
|
|
36
|
+
case C.Connecting:
|
|
37
|
+
(t = e.onConnectionStateChange) == null || t.call(e, g.Connecting);
|
|
38
|
+
break;
|
|
39
|
+
case C.Connected:
|
|
40
|
+
i("LiveKit room connected successfully"), v = !0, (o = e.onConnectionStateChange) == null || o.call(e, g.Connected);
|
|
41
|
+
break;
|
|
42
|
+
case C.Disconnected:
|
|
43
|
+
i("LiveKit room disconnected"), v = !1, (r = e.onConnectionStateChange) == null || r.call(e, g.Disconnected);
|
|
44
|
+
break;
|
|
45
|
+
case C.Reconnecting:
|
|
46
|
+
i("LiveKit room reconnecting..."), (s = e.onConnectionStateChange) == null || s.call(e, g.Connecting);
|
|
47
|
+
break;
|
|
48
|
+
case C.SignalReconnecting:
|
|
49
|
+
i("LiveKit room signal reconnecting..."), (S = e.onConnectionStateChange) == null || S.call(e, g.Connecting);
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}), a.on(d.ConnectionQualityChanged, (n, t) => {
|
|
53
|
+
var o;
|
|
54
|
+
t != null && t.isLocal && n === "poor" && (i("Connection quality is poor"), (o = e.onConnectivityStateChange) == null || o.call(e, U.Weak));
|
|
55
|
+
}), a.on(d.ParticipantConnected, (n) => {
|
|
56
|
+
i("Participant connected:", n.identity);
|
|
57
|
+
}), a.on(d.TrackSubscribed, (n, t, o) => {
|
|
58
|
+
var r, s;
|
|
59
|
+
i(`Track subscribed: ${n.kind} from ${o.identity}`), c ? c.addTrack(n.mediaStreamTrack) : c = new MediaStream([n.mediaStreamTrack]), (r = e.onSrcObjectReady) == null || r.call(e, c), n.kind === "video" && ((s = e.onVideoStateChange) == null || s.call(e, P.Start));
|
|
60
|
+
}), a.on(d.TrackUnsubscribed, (n, t, o) => {
|
|
61
|
+
var r;
|
|
62
|
+
i(`Track unsubscribed: ${n.kind} from ${o.identity}`), n.kind === "video" && ((r = e.onVideoStateChange) == null || r.call(e, P.Stop));
|
|
63
|
+
}), a.on(d.DataReceived, (n, t) => {
|
|
64
|
+
var r, s, S, D, _;
|
|
65
|
+
const o = new TextDecoder().decode(n);
|
|
66
|
+
i("Data received:", o);
|
|
67
|
+
try {
|
|
68
|
+
const m = JSON.parse(o);
|
|
69
|
+
m.subject === $.StreamStarted && ((r = m.metadata) != null && r.videoId) ? (y = m.metadata.videoId, (s = e.onVideoIdChange) == null || s.call(e, y), (S = e.onAgentActivityStateChange) == null || S.call(e, T.Talking)) : m.subject === $.StreamDone && (y = null, (D = e.onVideoIdChange) == null || D.call(e, y), (_ = e.onAgentActivityStateChange) == null || _.call(e, T.Idle));
|
|
70
|
+
} catch (m) {
|
|
71
|
+
i("Failed to parse data channel message:", m);
|
|
72
|
+
}
|
|
73
|
+
}), (E = e.onConnectionStateChange) == null || E.call(e, g.New);
|
|
74
|
+
const M = Q(V, j || q, u, e.onError);
|
|
75
|
+
let f, A;
|
|
76
|
+
try {
|
|
77
|
+
const n = await M.createStream({
|
|
78
|
+
transport_provider: J.Livekit,
|
|
79
|
+
chat_id: p.chat_id
|
|
80
|
+
}), { agent_id: t, session_id: o, session_token: r, session_url: s } = n;
|
|
81
|
+
f = t, A = o, await a.connect(s, r), i("LiveKit room joined successfully");
|
|
82
|
+
} catch (n) {
|
|
83
|
+
throw i("Failed to connect to LiveKit room:", n), (K = e.onConnectionStateChange) == null || K.call(e, g.Fail), (I = e.onError) == null || I.call(e, n, { streamId: "" }), n;
|
|
84
|
+
}
|
|
85
|
+
F.enrich({
|
|
86
|
+
"stream-type": L
|
|
87
|
+
});
|
|
88
|
+
async function R(n) {
|
|
89
|
+
var t, o;
|
|
90
|
+
if (!v || !a) {
|
|
91
|
+
i("Room is not connected for sending messages"), (t = e.onError) == null || t.call(e, new Error("Room is not connected for sending messages"), {
|
|
92
|
+
streamId: f
|
|
93
|
+
});
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
await a.localParticipant.publishData(new TextEncoder().encode(n), { reliable: !0 });
|
|
98
|
+
} catch (r) {
|
|
99
|
+
i("Error sending data channel message", r), (o = e.onError) == null || o.call(e, r, { streamId: f });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
speak(n) {
|
|
104
|
+
const t = JSON.stringify({
|
|
105
|
+
type: "speak",
|
|
106
|
+
payload: n
|
|
107
|
+
});
|
|
108
|
+
return R(t);
|
|
109
|
+
},
|
|
110
|
+
async disconnect() {
|
|
111
|
+
var n, t;
|
|
112
|
+
a && (await a.disconnect(), a = null), c && (c.getTracks().forEach((o) => o.stop()), c = null), v = !1, (n = e.onConnectionStateChange) == null || n.call(e, g.Completed), (t = e.onAgentActivityStateChange) == null || t.call(e, T.Idle);
|
|
113
|
+
},
|
|
114
|
+
sendDataChannelMessage: R,
|
|
115
|
+
sessionId: A,
|
|
116
|
+
streamId: f,
|
|
117
|
+
streamType: L,
|
|
118
|
+
interruptAvailable: !0,
|
|
119
|
+
triggersAvailable: !1
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
export {
|
|
123
|
+
H as createLiveKitStreamingManager
|
|
124
|
+
};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { StreamingManager } from '../streaming-manager';
|
|
2
|
-
import { Agent, AgentManagerOptions, AgentsAPI, Chat, CreateStreamOptions } from '../../types';
|
|
2
|
+
import { Agent, AgentManagerOptions, AgentsAPI, Chat, CreateStreamOptions, CreateStreamV2Options } from '../../types';
|
|
3
3
|
import { Analytics } from '../analytics/mixpanel';
|
|
4
4
|
|
|
5
5
|
type ConnectToManagerOptions = AgentManagerOptions & {
|
|
6
6
|
callbacks: AgentManagerOptions['callbacks'] & {
|
|
7
7
|
onVideoIdChange?: (videoId: string | null) => void;
|
|
8
8
|
};
|
|
9
|
+
chatId?: string;
|
|
9
10
|
};
|
|
10
11
|
export declare function initializeStreamAndChat(agent: Agent, options: ConnectToManagerOptions, agentsApi: AgentsAPI, analytics: Analytics, chat?: Chat): Promise<{
|
|
11
12
|
chat?: Chat;
|
|
12
|
-
streamingManager?: StreamingManager<CreateStreamOptions>;
|
|
13
|
+
streamingManager?: StreamingManager<CreateStreamOptions | CreateStreamV2Options>;
|
|
13
14
|
}>;
|
|
14
15
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { CreateStreamOptions, PayloadType, StreamType } from '../../types';
|
|
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,3 +1,13 @@
|
|
|
1
|
-
import { Agent, CreateStreamOptions, StreamingManagerOptions } from '../../types';
|
|
1
|
+
import { Agent, CreateStreamOptions, CreateStreamV2Options, StreamingManagerOptions } from '../../types';
|
|
2
|
+
import { StreamingManager } from './common';
|
|
2
3
|
|
|
3
|
-
export declare
|
|
4
|
+
export declare enum StreamApiVersion {
|
|
5
|
+
V1 = "v1",
|
|
6
|
+
V2 = "v2"
|
|
7
|
+
}
|
|
8
|
+
export type ExtendedStreamOptions = ({
|
|
9
|
+
version: StreamApiVersion.V1;
|
|
10
|
+
} & CreateStreamOptions) | ({
|
|
11
|
+
version: StreamApiVersion.V2;
|
|
12
|
+
} & CreateStreamV2Options);
|
|
13
|
+
export declare function createStreamingManager(agent: Agent, streamOptions: ExtendedStreamOptions, options: StreamingManagerOptions): Promise<StreamingManager<CreateStreamOptions | CreateStreamV2Options>>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export { createStreamingManager } from './factory';
|
|
1
|
+
export { StreamApiVersion as StreamApiVersion, createStreamingManager } from './factory';
|
|
2
|
+
export type { ExtendedStreamOptions } from './factory';
|
|
2
3
|
export type { StreamingManager } from './common';
|
|
4
|
+
export type { LiveKitStreamingManager } from './livekit-manager';
|
|
3
5
|
export * from './webrtc-manager';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CreateStreamOptions, StreamingManagerOptions } from '../../types';
|
|
1
|
+
import { CreateStreamOptions, CreateStreamV2Options, StreamingManagerOptions } from '../../types';
|
|
2
2
|
import { StreamingManager } from './common';
|
|
3
3
|
|
|
4
|
-
export declare function createLiveKitStreamingManager<T extends
|
|
4
|
+
export declare function createLiveKitStreamingManager<T extends CreateStreamV2Options>(agentId: string, agent: T, options: StreamingManagerOptions): Promise<StreamingManager<T>>;
|
|
5
5
|
export type LiveKitStreamingManager<T extends CreateStreamOptions> = StreamingManager<T>;
|
|
@@ -61,11 +61,17 @@ export interface ManagerCallbacks {
|
|
|
61
61
|
}) => void;
|
|
62
62
|
}
|
|
63
63
|
export type ManagerCallbackKeys = keyof ManagerCallbacks;
|
|
64
|
+
export interface StreamEndUserData {
|
|
65
|
+
distinct_id?: string;
|
|
66
|
+
plan?: string;
|
|
67
|
+
}
|
|
64
68
|
export interface TalkStreamOptions extends CreateTalkStreamRequest {
|
|
65
69
|
fluent?: boolean;
|
|
70
|
+
end_user_data?: StreamEndUserData;
|
|
66
71
|
}
|
|
67
72
|
export interface ClipStreamOptions extends CreateClipStreamRequest {
|
|
68
73
|
fluent?: boolean;
|
|
74
|
+
end_user_data?: StreamEndUserData;
|
|
69
75
|
}
|
|
70
76
|
export type CreateStreamOptions = TalkStreamOptions | ClipStreamOptions;
|
|
71
77
|
export type PayloadType<T> = T extends TalkStreamOptions ? SendTalkStreamPayload : T extends ClipStreamOptions ? SendClipStreamPayload : never;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export declare enum
|
|
1
|
+
export declare enum TransportProvider {
|
|
2
2
|
Livekit = "livekit"
|
|
3
3
|
}
|
|
4
4
|
export interface CreateStreamV2Options {
|
|
5
|
-
|
|
5
|
+
transport_provider: TransportProvider.Livekit;
|
|
6
|
+
chat_id?: string;
|
|
6
7
|
}
|
|
7
8
|
export interface CreateStreamV2Response {
|
|
8
9
|
agent_id: 'string';
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|