@vapi-ai/web 2.6.1 → 2.6.2

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/dist/vapi.d.ts CHANGED
@@ -127,6 +127,17 @@ export default class Vapi extends VapiEventEmitter {
127
127
  private cleanup;
128
128
  private isMobileDevice;
129
129
  private sleep;
130
+ /**
131
+ * Reports a failed audio processing update on the SDK's `error` event.
132
+ *
133
+ * Daily applies input settings inside its remotely loaded call machine, so a
134
+ * failure - Krisp's `KrispInitError: Canceled`, for example - arrives as a
135
+ * rejected promise, which a synchronous try/catch around
136
+ * `updateInputSettings()` cannot see. Without this the rejection escapes to
137
+ * the page as an unhandled rejection instead of reaching the listeners
138
+ * consumers register. Audio processing is non-critical, so the call continues.
139
+ */
140
+ private emitAudioProcessingError;
130
141
  start(assistant?: CreateAssistantDTO | string, assistantOverrides?: AssistantOverrides, squad?: CreateSquadDTO | string, workflow?: CreateWorkflowDTO | string, workflowOverrides?: WorkflowOverrides, options?: StartCallOptions): Promise<Call | null>;
131
142
  private onAppMessage;
132
143
  private handleRemoteParticipantsAudioLevel;
package/dist/vapi.js CHANGED
@@ -141,6 +141,24 @@ class Vapi extends VapiEventEmitter {
141
141
  async sleep(ms) {
142
142
  return new Promise((resolve) => setTimeout(resolve, ms));
143
143
  }
144
+ /**
145
+ * Reports a failed audio processing update on the SDK's `error` event.
146
+ *
147
+ * Daily applies input settings inside its remotely loaded call machine, so a
148
+ * failure - Krisp's `KrispInitError: Canceled`, for example - arrives as a
149
+ * rejected promise, which a synchronous try/catch around
150
+ * `updateInputSettings()` cannot see. Without this the rejection escapes to
151
+ * the page as an unhandled rejection instead of reaching the listeners
152
+ * consumers register. Audio processing is non-critical, so the call continues.
153
+ */
154
+ emitAudioProcessingError(stage, error) {
155
+ this.emit('error', {
156
+ type: `${stage}-error`,
157
+ stage,
158
+ error: serializeError(error),
159
+ timestamp: new Date().toISOString(),
160
+ });
161
+ }
144
162
  async start(assistant, assistantOverrides, squad, workflow, workflowOverrides, options) {
145
163
  const startTime = Date.now();
146
164
  // Input validation with detailed error messages
@@ -551,6 +569,9 @@ class Vapi extends VapiEventEmitter {
551
569
  })
552
570
  .then(() => {
553
571
  (0, daily_guards_1.safeSetLocalAudio)(this.call, true);
572
+ })
573
+ .catch((error) => {
574
+ this.emitAudioProcessingError('audio-processor-recovery', error);
554
575
  });
555
576
  }
556
577
  });
@@ -562,12 +583,16 @@ class Vapi extends VapiEventEmitter {
562
583
  });
563
584
  const audioProcessingStartTime = Date.now();
564
585
  try {
565
- this.call.updateInputSettings({
586
+ this.call
587
+ .updateInputSettings({
566
588
  audio: {
567
589
  processor: {
568
590
  type: 'noise-cancellation',
569
591
  },
570
592
  },
593
+ })
594
+ .catch((error) => {
595
+ this.emitAudioProcessingError('audio-processing-setup', error);
571
596
  });
572
597
  const audioProcessingDuration = Date.now() - audioProcessingStartTime;
573
598
  this.emit('call-start-progress', {
@@ -1007,6 +1032,9 @@ class Vapi extends VapiEventEmitter {
1007
1032
  })
1008
1033
  .then(() => {
1009
1034
  (0, daily_guards_1.safeSetLocalAudio)(this.call, true);
1035
+ })
1036
+ .catch((error) => {
1037
+ this.emitAudioProcessingError('audio-processor-recovery', error);
1010
1038
  });
1011
1039
  }
1012
1040
  });
@@ -1155,12 +1183,16 @@ class Vapi extends VapiEventEmitter {
1155
1183
  });
1156
1184
  const audioProcessingStartTime = Date.now();
1157
1185
  try {
1158
- this.call.updateInputSettings({
1186
+ this.call
1187
+ .updateInputSettings({
1159
1188
  audio: {
1160
1189
  processor: {
1161
1190
  type: 'noise-cancellation',
1162
1191
  },
1163
1192
  },
1193
+ })
1194
+ .catch((error) => {
1195
+ this.emitAudioProcessingError('audio-processing-setup', error);
1164
1196
  });
1165
1197
  const audioProcessingDuration = Date.now() - audioProcessingStartTime;
1166
1198
  this.emit('call-start-progress', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vapi-ai/web",
3
- "version": "2.6.1",
3
+ "version": "2.6.2",
4
4
  "description": "",
5
5
  "main": "dist/vapi.js",
6
6
  "types": "dist/vapi.d.ts",
package/vapi.ts CHANGED
@@ -368,6 +368,28 @@ export default class Vapi extends VapiEventEmitter {
368
368
  return new Promise((resolve) => setTimeout(resolve, ms));
369
369
  }
370
370
 
371
+ /**
372
+ * Reports a failed audio processing update on the SDK's `error` event.
373
+ *
374
+ * Daily applies input settings inside its remotely loaded call machine, so a
375
+ * failure - Krisp's `KrispInitError: Canceled`, for example - arrives as a
376
+ * rejected promise, which a synchronous try/catch around
377
+ * `updateInputSettings()` cannot see. Without this the rejection escapes to
378
+ * the page as an unhandled rejection instead of reaching the listeners
379
+ * consumers register. Audio processing is non-critical, so the call continues.
380
+ */
381
+ private emitAudioProcessingError(
382
+ stage: 'audio-processing-setup' | 'audio-processor-recovery',
383
+ error: unknown,
384
+ ) {
385
+ this.emit('error', {
386
+ type: `${stage}-error`,
387
+ stage,
388
+ error: serializeError(error),
389
+ timestamp: new Date().toISOString(),
390
+ });
391
+ }
392
+
371
393
  async start(
372
394
  assistant?: CreateAssistantDTO | string,
373
395
  assistantOverrides?: AssistantOverrides,
@@ -828,6 +850,9 @@ export default class Vapi extends VapiEventEmitter {
828
850
  })
829
851
  .then(() => {
830
852
  safeSetLocalAudio(this.call, true);
853
+ })
854
+ .catch((error) => {
855
+ this.emitAudioProcessingError('audio-processor-recovery', error);
831
856
  });
832
857
  }
833
858
  });
@@ -842,14 +867,18 @@ export default class Vapi extends VapiEventEmitter {
842
867
  const audioProcessingStartTime = Date.now();
843
868
 
844
869
  try {
845
- this.call.updateInputSettings({
846
- audio: {
847
- processor: {
848
- type: 'noise-cancellation',
870
+ this.call
871
+ .updateInputSettings({
872
+ audio: {
873
+ processor: {
874
+ type: 'noise-cancellation',
875
+ },
849
876
  },
850
- },
851
- });
852
-
877
+ })
878
+ .catch((error) => {
879
+ this.emitAudioProcessingError('audio-processing-setup', error);
880
+ });
881
+
853
882
  const audioProcessingDuration = Date.now() - audioProcessingStartTime;
854
883
  this.emit('call-start-progress', {
855
884
  stage: 'audio-processing-setup',
@@ -1352,6 +1381,9 @@ export default class Vapi extends VapiEventEmitter {
1352
1381
  })
1353
1382
  .then(() => {
1354
1383
  safeSetLocalAudio(this.call, true);
1384
+ })
1385
+ .catch((error) => {
1386
+ this.emitAudioProcessingError('audio-processor-recovery', error);
1355
1387
  });
1356
1388
  }
1357
1389
  });
@@ -1513,14 +1545,18 @@ export default class Vapi extends VapiEventEmitter {
1513
1545
  const audioProcessingStartTime = Date.now();
1514
1546
 
1515
1547
  try {
1516
- this.call.updateInputSettings({
1517
- audio: {
1518
- processor: {
1519
- type: 'noise-cancellation',
1548
+ this.call
1549
+ .updateInputSettings({
1550
+ audio: {
1551
+ processor: {
1552
+ type: 'noise-cancellation',
1553
+ },
1520
1554
  },
1521
- },
1522
- });
1523
-
1555
+ })
1556
+ .catch((error) => {
1557
+ this.emitAudioProcessingError('audio-processing-setup', error);
1558
+ });
1559
+
1524
1560
  const audioProcessingDuration = Date.now() - audioProcessingStartTime;
1525
1561
  this.emit('call-start-progress', {
1526
1562
  stage: 'audio-processing-setup',