@vapi-ai/web 2.2.3 → 2.2.5
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 +2495 -166
- package/dist/api.d.ts +10196 -6688
- package/dist/api.js +968 -351
- package/dist/vapi.d.ts +4 -2
- package/dist/vapi.js +22 -1
- package/generate-api.sh +11 -0
- package/package.json +2 -2
- package/vapi.ts +4 -2
package/dist/vapi.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export interface SayMessage {
|
|
|
16
16
|
type: 'say';
|
|
17
17
|
message: string;
|
|
18
18
|
endCallAfterSpoken?: boolean;
|
|
19
|
+
interruptionsEnabled?: boolean;
|
|
19
20
|
}
|
|
20
21
|
type VapiClientToServerMessage = AddMessageMessage | ControlMessages | SayMessage;
|
|
21
22
|
type VapiEventNames = 'call-end' | 'call-start' | 'volume-level' | 'speech-start' | 'speech-end' | 'message' | 'video' | 'error' | 'daily-participant-updated';
|
|
@@ -44,7 +45,7 @@ export default class Vapi extends VapiEventEmitter {
|
|
|
44
45
|
private dailyCallConfig;
|
|
45
46
|
private dailyCallObject;
|
|
46
47
|
private hasEmittedCallEndedStatus;
|
|
47
|
-
constructor(apiToken: string, apiBaseUrl?: string, dailyCallConfig?: Pick<DailyAdvancedConfig, 'avoidEval' | 'alwaysIncludeMicInPermissionPrompt'>, dailyCallObject?: Pick<DailyFactoryOptions, 'audioSource'>);
|
|
48
|
+
constructor(apiToken: string, apiBaseUrl?: string, dailyCallConfig?: Pick<DailyAdvancedConfig, 'avoidEval' | 'alwaysIncludeMicInPermissionPrompt'>, dailyCallObject?: Pick<DailyFactoryOptions, 'audioSource' | 'startAudioOff'>);
|
|
48
49
|
private cleanup;
|
|
49
50
|
private isMobileDevice;
|
|
50
51
|
private sleep;
|
|
@@ -55,8 +56,9 @@ export default class Vapi extends VapiEventEmitter {
|
|
|
55
56
|
send(message: VapiClientToServerMessage): void;
|
|
56
57
|
setMuted(mute: boolean): void;
|
|
57
58
|
isMuted(): boolean;
|
|
58
|
-
say(message: string, endCallAfterSpoken?: boolean): void;
|
|
59
|
+
say(message: string, endCallAfterSpoken?: boolean, interruptionsEnabled?: boolean): void;
|
|
59
60
|
setInputDevicesAsync(options: Parameters<DailyCall['setInputDevicesAsync']>[0]): void;
|
|
61
|
+
increaseMicLevel(gain: number): Promise<void>;
|
|
60
62
|
setOutputDeviceAsync(options: Parameters<DailyCall['setOutputDeviceAsync']>[0]): void;
|
|
61
63
|
getDailyCallObject(): DailyCall | null;
|
|
62
64
|
startScreenSharing(displayMediaOptions?: DisplayMediaStreamOptions, screenVideoSendSettings?: DailyVideoSendSettings): void;
|
package/dist/vapi.js
CHANGED
|
@@ -303,16 +303,37 @@ class Vapi extends VapiEventEmitter {
|
|
|
303
303
|
}
|
|
304
304
|
return this.call.localAudio() === false;
|
|
305
305
|
}
|
|
306
|
-
say(message, endCallAfterSpoken) {
|
|
306
|
+
say(message, endCallAfterSpoken, interruptionsEnabled) {
|
|
307
307
|
this.send({
|
|
308
308
|
type: 'say',
|
|
309
309
|
message,
|
|
310
310
|
endCallAfterSpoken,
|
|
311
|
+
interruptionsEnabled: interruptionsEnabled ?? false,
|
|
311
312
|
});
|
|
312
313
|
}
|
|
313
314
|
setInputDevicesAsync(options) {
|
|
314
315
|
this.call?.setInputDevicesAsync(options);
|
|
315
316
|
}
|
|
317
|
+
async increaseMicLevel(gain) {
|
|
318
|
+
if (!this.call) {
|
|
319
|
+
throw new Error('Call object is not available.');
|
|
320
|
+
}
|
|
321
|
+
try {
|
|
322
|
+
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
|
323
|
+
const audioContext = new AudioContext();
|
|
324
|
+
const source = audioContext.createMediaStreamSource(stream);
|
|
325
|
+
const gainNode = audioContext.createGain();
|
|
326
|
+
gainNode.gain.value = gain;
|
|
327
|
+
source.connect(gainNode);
|
|
328
|
+
const destination = audioContext.createMediaStreamDestination();
|
|
329
|
+
gainNode.connect(destination);
|
|
330
|
+
const [boostedTrack] = destination.stream.getAudioTracks();
|
|
331
|
+
await this.call.setInputDevicesAsync({ audioSource: boostedTrack });
|
|
332
|
+
}
|
|
333
|
+
catch (error) {
|
|
334
|
+
console.error("Error adjusting microphone level:", error);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
316
337
|
setOutputDeviceAsync(options) {
|
|
317
338
|
this.call?.setOutputDeviceAsync(options);
|
|
318
339
|
}
|
package/generate-api.sh
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Step 1: Manually download the Swagger JSON file
|
|
2
|
+
curl -o ./api-extended-json.json https://api.vapi.ai/api-extended-json
|
|
3
|
+
|
|
4
|
+
# Step 2: Find and replace transcript[transcriptType=\"final\"] with transcript[transcriptType='final']
|
|
5
|
+
sed -i '' 's/transcript\[transcriptType=\\"final\\"\]/transcript[transcriptType='\''final'\'']/g' ./api-extended-json.json
|
|
6
|
+
|
|
7
|
+
# Step 3: Generate TypeScript API using the edited JSON file
|
|
8
|
+
npx swagger-typescript-api -p ./api-extended-json.json -o . -n api.ts
|
|
9
|
+
|
|
10
|
+
# Step 4: Remove the edited JSON file
|
|
11
|
+
rm ./api-extended-json.json
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vapi-ai/web",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.5",
|
|
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": "
|
|
11
|
+
"generate-api": "./generate-api.sh",
|
|
12
12
|
"update": "./update.sh"
|
|
13
13
|
},
|
|
14
14
|
"repository": {
|
package/vapi.ts
CHANGED
|
@@ -35,6 +35,7 @@ export interface SayMessage {
|
|
|
35
35
|
type: 'say';
|
|
36
36
|
message: string;
|
|
37
37
|
endCallAfterSpoken?: boolean;
|
|
38
|
+
interruptionsEnabled?: boolean;
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
type VapiClientToServerMessage =
|
|
@@ -161,7 +162,7 @@ export default class Vapi extends VapiEventEmitter {
|
|
|
161
162
|
DailyAdvancedConfig,
|
|
162
163
|
'avoidEval' | 'alwaysIncludeMicInPermissionPrompt'
|
|
163
164
|
>,
|
|
164
|
-
dailyCallObject?: Pick<DailyFactoryOptions, 'audioSource'>,
|
|
165
|
+
dailyCallObject?: Pick<DailyFactoryOptions, 'audioSource' | 'startAudioOff'>,
|
|
165
166
|
) {
|
|
166
167
|
super();
|
|
167
168
|
client.baseUrl = apiBaseUrl ?? 'https://api.vapi.ai';
|
|
@@ -455,11 +456,12 @@ export default class Vapi extends VapiEventEmitter {
|
|
|
455
456
|
return this.call.localAudio() === false;
|
|
456
457
|
}
|
|
457
458
|
|
|
458
|
-
public say(message: string, endCallAfterSpoken?: boolean) {
|
|
459
|
+
public say(message: string, endCallAfterSpoken?: boolean, interruptionsEnabled?: boolean) {
|
|
459
460
|
this.send({
|
|
460
461
|
type: 'say',
|
|
461
462
|
message,
|
|
462
463
|
endCallAfterSpoken,
|
|
464
|
+
interruptionsEnabled: interruptionsEnabled ?? false,
|
|
463
465
|
});
|
|
464
466
|
}
|
|
465
467
|
|