@vapi-ai/web 2.2.1 → 2.2.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.
- package/api.ts +13798 -10177
- package/dist/vapi.js +2 -1
- package/package.json +3 -3
- package/vapi.ts +28 -1
package/dist/vapi.js
CHANGED
|
@@ -72,6 +72,7 @@ class Vapi extends VapiEventEmitter {
|
|
|
72
72
|
}
|
|
73
73
|
cleanup() {
|
|
74
74
|
this.started = false;
|
|
75
|
+
this.hasEmittedCallEndedStatus = false;
|
|
75
76
|
this.call?.destroy();
|
|
76
77
|
this.call = null;
|
|
77
78
|
this.speakingTimeout = null;
|
|
@@ -250,7 +251,7 @@ class Vapi extends VapiEventEmitter {
|
|
|
250
251
|
try {
|
|
251
252
|
const parsedMessage = JSON.parse(e.data);
|
|
252
253
|
this.emit('message', parsedMessage);
|
|
253
|
-
if (parsedMessage.type === 'status-update' && parsedMessage.status === 'ended') {
|
|
254
|
+
if (parsedMessage && 'type' in parsedMessage && 'status' in parsedMessage && parsedMessage.type === 'status-update' && parsedMessage.status === 'ended') {
|
|
254
255
|
this.hasEmittedCallEndedStatus = true;
|
|
255
256
|
}
|
|
256
257
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vapi-ai/web",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/vapi.js",
|
|
6
6
|
"types": "dist/vapi.d.ts",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"test": "jest",
|
|
9
9
|
"build": "tsc && tsc --declaration",
|
|
10
10
|
"start": "npm run generate-api && npm run build && node dist/vapi.js",
|
|
11
|
-
"generate-api": "npx swagger-typescript-api -p https://api.vapi.ai/api-json -o . -n api.ts",
|
|
11
|
+
"generate-api": "npx swagger-typescript-api -p https://api.vapi.ai/api-extended-json -o . -n api.ts",
|
|
12
12
|
"update": "./update.sh"
|
|
13
13
|
},
|
|
14
14
|
"repository": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://github.com/VapiAI/web#readme",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@daily-co/daily-js": "^0.
|
|
25
|
+
"@daily-co/daily-js": "^0.75.2",
|
|
26
26
|
"events": "^3.3.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
package/vapi.ts
CHANGED
|
@@ -172,6 +172,7 @@ export default class Vapi extends VapiEventEmitter {
|
|
|
172
172
|
|
|
173
173
|
private cleanup() {
|
|
174
174
|
this.started = false;
|
|
175
|
+
this.hasEmittedCallEndedStatus = false;
|
|
175
176
|
this.call?.destroy();
|
|
176
177
|
this.call = null;
|
|
177
178
|
this.speakingTimeout = null;
|
|
@@ -389,7 +390,7 @@ export default class Vapi extends VapiEventEmitter {
|
|
|
389
390
|
try {
|
|
390
391
|
const parsedMessage = JSON.parse(e.data);
|
|
391
392
|
this.emit('message', parsedMessage);
|
|
392
|
-
if (parsedMessage.type === 'status-update' && parsedMessage.status === 'ended') {
|
|
393
|
+
if (parsedMessage && 'type' in parsedMessage && 'status' in parsedMessage && parsedMessage.type === 'status-update' && parsedMessage.status === 'ended') {
|
|
393
394
|
this.hasEmittedCallEndedStatus = true;
|
|
394
395
|
}
|
|
395
396
|
} catch (parseError) {
|
|
@@ -468,6 +469,32 @@ export default class Vapi extends VapiEventEmitter {
|
|
|
468
469
|
this.call?.setInputDevicesAsync(options);
|
|
469
470
|
}
|
|
470
471
|
|
|
472
|
+
public async increaseMicLevel(gain: number) {
|
|
473
|
+
if (!this.call) {
|
|
474
|
+
throw new Error('Call object is not available.');
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
try {
|
|
478
|
+
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
|
479
|
+
const audioContext = new AudioContext();
|
|
480
|
+
|
|
481
|
+
const source = audioContext.createMediaStreamSource(stream);
|
|
482
|
+
|
|
483
|
+
const gainNode = audioContext.createGain();
|
|
484
|
+
gainNode.gain.value = gain;
|
|
485
|
+
|
|
486
|
+
source.connect(gainNode);
|
|
487
|
+
|
|
488
|
+
const destination = audioContext.createMediaStreamDestination();
|
|
489
|
+
gainNode.connect(destination);
|
|
490
|
+
|
|
491
|
+
const [boostedTrack] = destination.stream.getAudioTracks();
|
|
492
|
+
await this.call.setInputDevicesAsync({ audioSource: boostedTrack });
|
|
493
|
+
} catch (error) {
|
|
494
|
+
console.error("Error adjusting microphone level:", error);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
471
498
|
public setOutputDeviceAsync(
|
|
472
499
|
options: Parameters<DailyCall['setOutputDeviceAsync']>[0],
|
|
473
500
|
) {
|