@d-id/client-sdk 2.0.6 → 2.0.7-staging.404
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 +27 -16
- package/dist/{index-BLArKcFJ.js → index-BIUmlXCc.js} +2922 -2901
- package/dist/index.js +20 -18
- package/dist/index.umd.cjs +5 -5
- package/dist/{livekit-manager-BPAUUVXy.js → livekit-manager-CyKx_r7E.js} +200 -226
- 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/services/streaming-manager/advanced.test.d.ts +0 -4
- package/dist/src/services/streaming-manager/common.d.ts +8 -20
- package/dist/src/services/streaming-manager/edge-cases.test.d.ts +0 -4
- package/dist/src/services/streaming-manager/livekit-manager.d.ts +0 -6
- package/dist/src/services/streaming-manager/webrtc-core.test.d.ts +0 -4
- package/dist/src/types/entities/agents/agent.d.ts +5 -0
- package/dist/src/types/entities/agents/manager.d.ts +10 -2
- package/dist/src/types/entities/knowledge/document.d.ts +13 -3
- package/dist/src/types/stream/data-channel.d.ts +16 -0
- package/dist/src/types/stream/stream.d.ts +34 -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,18 +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
|
+
```
|
|
171
|
+
|
|
172
|
+
- **`agentManager.sendDataChannelMessage(topic, payload)`**
|
|
173
|
+
**Supported only with Expressive (V4) agents.**
|
|
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.
|
|
175
|
+
|
|
176
|
+
```javascript
|
|
177
|
+
import { PublicDataChannelTopic } from '@d-id/client-sdk';
|
|
178
|
+
|
|
179
|
+
await agentManager.sendDataChannelMessage(PublicDataChannelTopic.Presentation, { type: 'navigate', slide: 3 });
|
|
180
|
+
```
|
|
173
181
|
|
|
174
182
|
### ➤ ✴️ Callback Functions
|
|
175
183
|
|
|
@@ -207,21 +215,24 @@ Callback functions enable you to manage various events throughout the SDK lifecy
|
|
|
207
215
|
}
|
|
208
216
|
```
|
|
209
217
|
|
|
210
|
-
- **`onConnectionStateChange(state):`**
|
|
218
|
+
- **`onConnectionStateChange(state, reason):`**
|
|
211
219
|
Displaying the different connection states with the Agent's WebRTC stream connection
|
|
212
220
|
Triggered when `agentManager.connect(), agentManager.reconnect(), agentManager.disconnect()` are called.
|
|
213
221
|
|
|
214
222
|
```javascript
|
|
215
|
-
onConnectionStateChange(state) {
|
|
216
|
-
console.log("onConnectionStateChange(): ", state)
|
|
223
|
+
onConnectionStateChange(state, reason) {
|
|
224
|
+
console.log("onConnectionStateChange(): ", state, reason)
|
|
217
225
|
if (state == "connected") {
|
|
218
226
|
console.log("I'm ready to go!")
|
|
219
227
|
}
|
|
220
228
|
}
|
|
221
229
|
```
|
|
222
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
|
+
|
|
223
233
|
```javascript Example Values
|
|
224
234
|
state: ['new', 'fail', 'connecting', 'connected', 'disconnected', 'closed'];
|
|
235
|
+
reason: ['ok', 'unknown_error', 'network_issue', 'message_limit', 'time_limit', 'inactivity', 'ended_by_agent'];
|
|
225
236
|
```
|
|
226
237
|
|
|
227
238
|
- **`onNewMessage(messages, type)`:**
|