@d-id/client-sdk 1.1.0-beta.1 → 1.1.0-beta.3

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,5 +1,5 @@
1
- import { CreateStreamOptions, PayloadType, StreamingManagerOptions } from '../../types/index';
2
- export declare function createStreamingManager<T extends CreateStreamOptions>(agentId: string, agent: T, { debug, callbacks, auth, baseURL, warmup }: StreamingManagerOptions): Promise<{
1
+ import { CreateStreamOptions, PayloadType, StreamType, StreamingManagerOptions } from '../../types/index';
2
+ export declare function createStreamingManager<T extends CreateStreamOptions>(agentId: string, agent: T, { debug, callbacks, auth, baseURL }: StreamingManagerOptions): Promise<{
3
3
  /**
4
4
  * Method to send request to server to get clip or talk depend on you payload
5
5
  * @param payload
@@ -17,5 +17,6 @@ export declare function createStreamingManager<T extends CreateStreamOptions>(ag
17
17
  * Id of current RTC stream
18
18
  */
19
19
  streamId: string;
20
+ streamType: StreamType;
20
21
  }>;
21
22
  export type StreamingManager<T extends CreateStreamOptions> = Awaited<ReturnType<typeof createStreamingManager<T>>>;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="node" />
2
- import { StreamingState } from '../../../types';
2
+ import { StreamingState, ConnectivityState } from '../../../types';
3
3
  import { VideoRTCStatsReport } from './report';
4
- export declare function pollStats(peerConnection: RTCPeerConnection, getIsConnected: () => boolean, onConnected: () => void, onVideoStateChange?: (state: StreamingState, statsReport?: VideoRTCStatsReport) => void, warmup?: boolean, shouldWaitForGreeting?: boolean): NodeJS.Timeout;
4
+ export declare function pollStats(peerConnection: RTCPeerConnection, getIsConnected: () => boolean, onConnected: () => void, onVideoStateChange?: (state: StreamingState, statsReport?: VideoRTCStatsReport) => void, onConnectivityStateChange?: (state: ConnectivityState) => void, warmup?: boolean, shouldWaitForGreeting?: boolean): NodeJS.Timeout;
@@ -3,6 +3,9 @@ export interface VideoRTCStatsReport {
3
3
  webRTCStats: {
4
4
  anomalies: AnalyticsRTCStatsReport[];
5
5
  aggregateReport: AnalyticsRTCStatsReport;
6
+ minJitterDelayInInterval: number;
7
+ maxJitterDelayInInterval: number;
8
+ avgJitterDelayInInterval: number;
6
9
  };
7
10
  codec: string;
8
11
  resolution: string;
@@ -1,7 +1,7 @@
1
1
  import { STTTokenResponse } from '../..';
2
- import { SupportedStreamScipt } from '../../stream-script';
3
2
  import { Auth } from '../../auth';
4
- import { CompatibilityMode, ConnectionState, SendStreamPayloadResponse, StreamEvents, StreamingState } from '../../stream';
3
+ import { AgentActivityState, CompatibilityMode, ConnectionState, ConnectivityState, SendStreamPayloadResponse, StreamEvents, StreamType, StreamingState } from '../../stream';
4
+ import { SupportedStreamScript } from '../../stream-script';
5
5
  import { Agent } from './agent';
6
6
  import { ChatMode, ChatResponse, Message, RatingEntity } from './chat';
7
7
  /**
@@ -67,10 +67,20 @@ interface ManagerCallbacks {
67
67
  * @param mode - ChatMode
68
68
  */
69
69
  onModeChange?(mode: ChatMode): void;
70
+ /**
71
+ * Optional callback function that will be triggered each time the user internet connectivity state change by realtime estimated bitrate
72
+ * @param state - ConnectivityState
73
+ */
74
+ onConnectivityStateChange?(state: ConnectivityState): void;
70
75
  /**
71
76
  * Optional callback function that will be triggered on fetch request errors
72
77
  */
73
78
  onError?: (error: Error, errorData?: object) => void;
79
+ /**
80
+ * Optional callback function that will be triggered each time the agent activity state changes
81
+ * @param state - AgentActivityState
82
+ */
83
+ onAgentActivityStateChange?(state: AgentActivityState): void;
74
84
  }
75
85
  interface StreamOptions {
76
86
  /**
@@ -130,6 +140,10 @@ export interface AgentManager {
130
140
  * To know more about agents go to https://docs.d-id.com/reference/agents
131
141
  */
132
142
  agent: Agent;
143
+ /**
144
+ * Get the current stream type of the agent
145
+ */
146
+ getStreamType: () => StreamType;
133
147
  /**
134
148
  * Array of starter messages that will be sent to the agent when the chat starts
135
149
  */
@@ -172,7 +186,7 @@ export interface AgentManager {
172
186
  * Method to make your agent read the text you provide or reproduce sound
173
187
  * @param payload
174
188
  */
175
- speak: (payload: SupportedStreamScipt | string) => Promise<SendStreamPayloadResponse>;
189
+ speak: (payload: SupportedStreamScript | string) => Promise<SendStreamPayloadResponse>;
176
190
  /**
177
191
  * Method to change the mode of the chat
178
192
  * @param mode - ChatMode
@@ -117,5 +117,6 @@ export interface SendClipStreamPayload extends StickyRequest {
117
117
  * @example "https://path.to.directory/"
118
118
  */
119
119
  raw_result_url?: string;
120
+ metadata: Record<string, any>;
120
121
  }
121
122
  export {};
@@ -33,6 +33,7 @@ export interface ICreateStreamRequestResponse extends StickyRequest {
33
33
  jsep: Jsep;
34
34
  offer: any;
35
35
  ice_servers: IceServer[];
36
+ fluent?: boolean;
36
37
  }
37
38
  export interface IceCandidate {
38
39
  /**
@@ -9,6 +9,16 @@ export declare enum StreamingState {
9
9
  Start = "START",
10
10
  Stop = "STOP"
11
11
  }
12
+ export declare enum ConnectivityState {
13
+ Strong = "STRONG",
14
+ Weak = "WEAK",
15
+ Unknown = "UNKNOWN"
16
+ }
17
+ export declare enum AgentActivityState {
18
+ Idle = "IDLE",
19
+ Talking = "TALKING"
20
+ }
21
+ export declare const DataChannelSignalMap: Record<string, StreamingState>;
12
22
  export declare enum StreamEvents {
13
23
  ChatAnswer = "chat/answer",
14
24
  ChatPartial = "chat/partial",
@@ -31,12 +41,18 @@ export declare enum ConnectionState {
31
41
  Completed = "completed",
32
42
  Disconnected = "disconnected"
33
43
  }
44
+ export declare enum StreamType {
45
+ Legacy = "legacy",
46
+ Fluent = "fluent"
47
+ }
34
48
  export interface ManagerCallbacks {
35
49
  onMessage?: (event: string, data: string) => void;
36
50
  onConnectionStateChange?: (state: ConnectionState) => void;
37
51
  onVideoStateChange?: (state: StreamingState, report?: VideoRTCStatsReport) => void;
38
52
  onSrcObjectReady?: (value: MediaStream) => void;
39
53
  onError?: (error: Error, errorData: object) => void;
54
+ onConnectivityStateChange?: (state: ConnectivityState) => void;
55
+ onAgentActivityStateChange?: (state: AgentActivityState) => void;
40
56
  }
41
57
  export type ManagerCallbackKeys = keyof ManagerCallbacks;
42
58
  export interface TalkStreamOptions extends CreateTalkStreamRequest {
@@ -60,7 +76,6 @@ export interface StreamingManagerOptions {
60
76
  callbacks: ManagerCallbacks;
61
77
  baseURL?: string;
62
78
  debug?: boolean;
63
- warmup?: boolean;
64
79
  auth: Auth;
65
80
  analytics: Analytics;
66
81
  }
@@ -77,6 +92,8 @@ export interface SlimRTCStatsReport {
77
92
  framesDecoded: any;
78
93
  jitter: any;
79
94
  jitterBufferDelay: number;
95
+ jitterBufferEmittedCount: number;
96
+ avgJitterDelayInInterval: number;
80
97
  frameWidth: any;
81
98
  frameHeight: any;
82
99
  framesPerSecond: any;
@@ -94,6 +111,8 @@ export interface AnalyticsRTCStatsReport {
94
111
  framesDecoded: number;
95
112
  jitter: number;
96
113
  jitterBufferDelay: number;
114
+ jitterBufferEmittedCount: number;
115
+ avgJitterDelayInInterval: number;
97
116
  framesPerSecond: number;
98
117
  freezeCount: number;
99
118
  freezeDuration: number;
@@ -50,4 +50,4 @@ export interface Stream_LLM_Script {
50
50
  stream_audio?: boolean;
51
51
  }
52
52
  export type StreamScript = Stream_Text_Script | Stream_Audio_Script | Stream_LLM_Script;
53
- export type SupportedStreamScipt = Stream_Text_Script | Stream_Audio_Script;
53
+ export type SupportedStreamScript = Stream_Text_Script | Stream_Audio_Script;
@@ -10,4 +10,6 @@ export declare function getAnalyticsInfo(agent: Agent): {
10
10
  provider: import('../types/index').Providers | undefined;
11
11
  };
12
12
  };
13
+ export declare const sumFunc: (numbers: number[]) => number;
14
+ export declare const average: (numbers: number[]) => number;
13
15
  export declare function getStreamAnalyticsProps(data: any, agent: Agent, additionalProps: Record<string, any>): any;
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.0-beta.1",
4
+ "version": "1.1.0-beta.3",
5
5
  "type": "module",
6
6
  "description": "d-id client sdk",
7
7
  "repository": {
@@ -45,4 +45,4 @@
45
45
  "vite": "^5.1.4",
46
46
  "vite-plugin-dts": "^3.7.3"
47
47
  }
48
- }
48
+ }