@d-id/client-sdk 2.0.7 → 2.0.8
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/README.md +21 -20
- package/dist/{index-DeKPoqBL.js → index-CeqOE8FZ.js} +2280 -2269
- package/dist/index.js +22 -21
- package/dist/index.umd.cjs +5 -5
- package/dist/{livekit-manager-D7YZEQiJ.js → livekit-manager-aJg_E0hR.js} +160 -149
- package/dist/src/services/agent-manager/connect-to-manager.d.ts +2 -1
- package/dist/src/services/socket-manager/message-queue.d.ts +1 -1
- package/dist/src/types/entities/agents/manager.d.ts +2 -1
- package/dist/src/types/stream/stream.d.ts +19 -0
- package/dist/src/utils/stream-end.d.ts +5 -0
- package/dist/src/utils/stream-end.test.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -126,12 +126,10 @@ The `agentManager` object created during initialization has several built-in met
|
|
|
126
126
|
```
|
|
127
127
|
|
|
128
128
|
```javascript Audio File - JavaScript
|
|
129
|
-
let speak = agentManager.speak(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
);
|
|
129
|
+
let speak = agentManager.speak({
|
|
130
|
+
type: 'audio',
|
|
131
|
+
audio_url: 'http://www.yourwebsite.com/audio.mp3',
|
|
132
|
+
});
|
|
135
133
|
```
|
|
136
134
|
|
|
137
135
|
- **`agentManager.chat(string)`**
|
|
@@ -158,28 +156,28 @@ The `agentManager` object created during initialization has several built-in met
|
|
|
158
156
|
**Supported only with Expressive (V4) agents.**
|
|
159
157
|
Method to publish a microphone audio track to the session. Call after `connect()` to enable voice input.
|
|
160
158
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
159
|
+
```javascript
|
|
160
|
+
const micStream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
|
161
|
+
await agentManager.publishMicrophoneStream(micStream);
|
|
162
|
+
```
|
|
165
163
|
|
|
166
164
|
- **`agentManager.unpublishMicrophoneStream()`**
|
|
167
165
|
**Supported only with Expressive (V4) agents.**
|
|
168
166
|
Method to stop and remove the currently published microphone track from the session.
|
|
169
167
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
168
|
+
```javascript
|
|
169
|
+
await agentManager.unpublishMicrophoneStream();
|
|
170
|
+
```
|
|
173
171
|
|
|
174
172
|
- **`agentManager.sendDataChannelMessage(topic, payload)`**
|
|
175
173
|
**Supported only with Expressive (V4) agents.**
|
|
176
174
|
Method to send a JSON payload to the agent over a data-channel topic. `PublicDataChannelTopic` is exported from the package root and lists every topic this method accepts.
|
|
177
175
|
|
|
178
|
-
|
|
179
|
-
|
|
176
|
+
```javascript
|
|
177
|
+
import { PublicDataChannelTopic } from '@d-id/client-sdk';
|
|
180
178
|
|
|
181
|
-
|
|
182
|
-
|
|
179
|
+
await agentManager.sendDataChannelMessage(PublicDataChannelTopic.Presentation, { type: 'navigate', slide: 3 });
|
|
180
|
+
```
|
|
183
181
|
|
|
184
182
|
### ➤ ✴️ Callback Functions
|
|
185
183
|
|
|
@@ -217,21 +215,24 @@ Callback functions enable you to manage various events throughout the SDK lifecy
|
|
|
217
215
|
}
|
|
218
216
|
```
|
|
219
217
|
|
|
220
|
-
- **`onConnectionStateChange(state):`**
|
|
218
|
+
- **`onConnectionStateChange(state, reason):`**
|
|
221
219
|
Displaying the different connection states with the Agent's WebRTC stream connection
|
|
222
220
|
Triggered when `agentManager.connect(), agentManager.reconnect(), agentManager.disconnect()` are called.
|
|
223
221
|
|
|
224
222
|
```javascript
|
|
225
|
-
onConnectionStateChange(state) {
|
|
226
|
-
console.log("onConnectionStateChange(): ", state)
|
|
223
|
+
onConnectionStateChange(state, reason) {
|
|
224
|
+
console.log("onConnectionStateChange(): ", state, reason)
|
|
227
225
|
if (state == "connected") {
|
|
228
226
|
console.log("I'm ready to go!")
|
|
229
227
|
}
|
|
230
228
|
}
|
|
231
229
|
```
|
|
232
230
|
|
|
231
|
+
The second `reason` argument says why the connection reached that state. On `disconnected` it is a `StreamEndReason` when the server ended the stream on purpose, which lets you tell a deliberate end from a dropped connection. Any other value is an opaque transport diagnostic. `agentManager.reconnect()` still works after a deliberate end; it starts a new stream rather than resuming the old one.
|
|
232
|
+
|
|
233
233
|
```javascript Example Values
|
|
234
234
|
state: ['new', 'fail', 'connecting', 'connected', 'disconnected', 'closed'];
|
|
235
|
+
reason: ['ok', 'unknown_error', 'network_issue', 'message_limit', 'time_limit', 'inactivity', 'ended_by_agent'];
|
|
235
236
|
```
|
|
236
237
|
|
|
237
238
|
- **`onNewMessage(messages, type)`:**
|