@vapi-ai/web 2.3.10 → 2.4.0

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/api.js CHANGED
@@ -146,9 +146,10 @@ class HttpClient {
146
146
  const r = response;
147
147
  r.data = null;
148
148
  r.error = null;
149
+ const responseToParse = responseFormat ? response.clone() : response;
149
150
  const data = !responseFormat
150
151
  ? r
151
- : await response[responseFormat]()
152
+ : await responseToParse[responseFormat]()
152
153
  .then((data) => {
153
154
  if (r.ok) {
154
155
  r.data = data;
@@ -705,7 +706,7 @@ class Api extends HttpClient {
705
706
  ...params,
706
707
  }),
707
708
  /**
708
- * @description Creates a new chat. Requires at least one of: assistantId/assistant, sessionId, or previousChatId. Note: sessionId and previousChatId are mutually exclusive.
709
+ * @description Creates a new chat with optional SMS delivery via transport field. Requires at least one of: assistantId/assistant, sessionId, or previousChatId. Note: sessionId and previousChatId are mutually exclusive. Transport field enables SMS delivery with two modes: (1) New conversation - provide transport.phoneNumberId and transport.customer to create a new session, (2) Existing conversation - provide sessionId to use existing session data. Cannot specify both sessionId and transport fields together. The transport.useLLMGeneratedMessageForOutbound flag controls whether input is processed by LLM (true, default) or forwarded directly as SMS (false).
709
710
  *
710
711
  * @tags Chats
711
712
  * @name ChatControllerCreateChat
@@ -1732,6 +1733,159 @@ class Api extends HttpClient {
1732
1733
  ...params,
1733
1734
  }),
1734
1735
  };
1736
+ eval = {
1737
+ /**
1738
+ * No description
1739
+ *
1740
+ * @tags Eval
1741
+ * @name EvalControllerCreate
1742
+ * @summary Create Eval
1743
+ * @request POST:/eval
1744
+ * @secure
1745
+ */
1746
+ evalControllerCreate: (data, params = {}) => this.request({
1747
+ path: `/eval`,
1748
+ method: "POST",
1749
+ body: data,
1750
+ secure: true,
1751
+ type: ContentType.Json,
1752
+ format: "json",
1753
+ ...params,
1754
+ }),
1755
+ /**
1756
+ * No description
1757
+ *
1758
+ * @tags Eval
1759
+ * @name EvalControllerGetPaginated
1760
+ * @summary List Evals
1761
+ * @request GET:/eval
1762
+ * @secure
1763
+ */
1764
+ evalControllerGetPaginated: (query, params = {}) => this.request({
1765
+ path: `/eval`,
1766
+ method: "GET",
1767
+ query: query,
1768
+ secure: true,
1769
+ format: "json",
1770
+ ...params,
1771
+ }),
1772
+ /**
1773
+ * No description
1774
+ *
1775
+ * @tags Eval
1776
+ * @name EvalControllerUpdate
1777
+ * @summary Update Eval
1778
+ * @request PATCH:/eval/{id}
1779
+ * @secure
1780
+ */
1781
+ evalControllerUpdate: (id, data, params = {}) => this.request({
1782
+ path: `/eval/${id}`,
1783
+ method: "PATCH",
1784
+ body: data,
1785
+ secure: true,
1786
+ type: ContentType.Json,
1787
+ format: "json",
1788
+ ...params,
1789
+ }),
1790
+ /**
1791
+ * No description
1792
+ *
1793
+ * @tags Eval
1794
+ * @name EvalControllerRemove
1795
+ * @summary Delete Eval
1796
+ * @request DELETE:/eval/{id}
1797
+ * @secure
1798
+ */
1799
+ evalControllerRemove: (id, params = {}) => this.request({
1800
+ path: `/eval/${id}`,
1801
+ method: "DELETE",
1802
+ secure: true,
1803
+ format: "json",
1804
+ ...params,
1805
+ }),
1806
+ /**
1807
+ * No description
1808
+ *
1809
+ * @tags Eval
1810
+ * @name EvalControllerGet
1811
+ * @summary Get Eval
1812
+ * @request GET:/eval/{id}
1813
+ * @secure
1814
+ */
1815
+ evalControllerGet: (id, params = {}) => this.request({
1816
+ path: `/eval/${id}`,
1817
+ method: "GET",
1818
+ secure: true,
1819
+ format: "json",
1820
+ ...params,
1821
+ }),
1822
+ /**
1823
+ * No description
1824
+ *
1825
+ * @tags Eval
1826
+ * @name EvalControllerRemoveRun
1827
+ * @summary Delete Eval Run
1828
+ * @request DELETE:/eval/run/{id}
1829
+ * @secure
1830
+ */
1831
+ evalControllerRemoveRun: (id, params = {}) => this.request({
1832
+ path: `/eval/run/${id}`,
1833
+ method: "DELETE",
1834
+ secure: true,
1835
+ format: "json",
1836
+ ...params,
1837
+ }),
1838
+ /**
1839
+ * No description
1840
+ *
1841
+ * @tags Eval
1842
+ * @name EvalControllerGetRun
1843
+ * @summary Get Eval Run
1844
+ * @request GET:/eval/run/{id}
1845
+ * @secure
1846
+ */
1847
+ evalControllerGetRun: (id, params = {}) => this.request({
1848
+ path: `/eval/run/${id}`,
1849
+ method: "GET",
1850
+ secure: true,
1851
+ format: "json",
1852
+ ...params,
1853
+ }),
1854
+ /**
1855
+ * No description
1856
+ *
1857
+ * @tags Eval
1858
+ * @name EvalControllerRun
1859
+ * @summary Create Eval Run
1860
+ * @request POST:/eval/run
1861
+ * @secure
1862
+ */
1863
+ evalControllerRun: (data, params = {}) => this.request({
1864
+ path: `/eval/run`,
1865
+ method: "POST",
1866
+ body: data,
1867
+ secure: true,
1868
+ type: ContentType.Json,
1869
+ ...params,
1870
+ }),
1871
+ /**
1872
+ * No description
1873
+ *
1874
+ * @tags Eval
1875
+ * @name EvalControllerGetRunsPaginated
1876
+ * @summary List Eval Runs
1877
+ * @request GET:/eval/run
1878
+ * @secure
1879
+ */
1880
+ evalControllerGetRunsPaginated: (query, params = {}) => this.request({
1881
+ path: `/eval/run`,
1882
+ method: "GET",
1883
+ query: query,
1884
+ secure: true,
1885
+ format: "json",
1886
+ ...params,
1887
+ }),
1888
+ };
1735
1889
  org = {
1736
1890
  /**
1737
1891
  * No description
package/dist/vapi.d.ts CHANGED
@@ -79,7 +79,7 @@ export default class Vapi extends VapiEventEmitter {
79
79
  start(assistant?: CreateAssistantDTO | string, assistantOverrides?: AssistantOverrides, squad?: CreateSquadDTO | string, workflow?: CreateWorkflowDTO | string, workflowOverrides?: WorkflowOverrides): Promise<Call | null>;
80
80
  private onAppMessage;
81
81
  private handleRemoteParticipantsAudioLevel;
82
- stop(): void;
82
+ stop(): Promise<void>;
83
83
  send(message: VapiClientToServerMessage): void;
84
84
  setMuted(mute: boolean): void;
85
85
  isMuted(): boolean;
package/dist/vapi.js CHANGED
@@ -71,11 +71,13 @@ class Vapi extends VapiEventEmitter {
71
71
  this.dailyCallConfig = (0, daily_guards_1.createSafeDailyConfig)(dailyCallConfig);
72
72
  this.dailyCallObject = (0, daily_guards_1.createSafeDailyFactoryOptions)(dailyCallObject);
73
73
  }
74
- cleanup() {
74
+ async cleanup() {
75
75
  this.started = false;
76
76
  this.hasEmittedCallEndedStatus = false;
77
- this.call?.destroy();
78
- this.call = null;
77
+ if (this.call) {
78
+ await this.call.destroy();
79
+ this.call = null;
80
+ }
79
81
  this.speakingTimeout = null;
80
82
  }
81
83
  isMobileDevice() {
@@ -158,7 +160,7 @@ class Vapi extends VapiEventEmitter {
158
160
  timestamp: new Date().toISOString(),
159
161
  metadata: { action: 'cleanup-existing' }
160
162
  });
161
- this.cleanup();
163
+ await this.cleanup();
162
164
  }
163
165
  const isVideoRecordingEnabled = webCall?.artifactPlan?.videoRecordingEnabled ?? false;
164
166
  const isVideoEnabled = webCall?.assistant?.voice?.provider === 'tavus';
@@ -220,7 +222,7 @@ class Vapi extends VapiEventEmitter {
220
222
  if (isVideoRecordingEnabled) {
221
223
  this.call?.stopRecording();
222
224
  }
223
- this.cleanup();
225
+ this.cleanup().catch(console.error);
224
226
  });
225
227
  this.call.on('error', (error) => {
226
228
  this.emit('error', error);
@@ -537,7 +539,7 @@ class Vapi extends VapiEventEmitter {
537
539
  isMobile: this.isMobileDevice()
538
540
  }
539
541
  });
540
- this.cleanup();
542
+ await this.cleanup();
541
543
  return null;
542
544
  }
543
545
  }
@@ -585,10 +587,13 @@ class Vapi extends VapiEventEmitter {
585
587
  this.speakingTimeout = null;
586
588
  }, 1000);
587
589
  }
588
- stop() {
590
+ async stop() {
589
591
  this.started = false;
590
- this.call?.destroy();
591
- this.call = null;
592
+ if (this.call) {
593
+ await this.call.destroy();
594
+ this.call = null;
595
+ }
596
+ this.speakingTimeout = null;
592
597
  }
593
598
  send(message) {
594
599
  this.call?.sendAppMessage(JSON.stringify(message));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vapi-ai/web",
3
- "version": "2.3.10",
3
+ "version": "2.4.0",
4
4
  "description": "",
5
5
  "main": "dist/vapi.js",
6
6
  "types": "dist/vapi.d.ts",
@@ -30,7 +30,7 @@
30
30
  "node": ">=18.0.0"
31
31
  },
32
32
  "dependencies": {
33
- "@daily-co/daily-js": "^0.83.1",
33
+ "@daily-co/daily-js": "^0.84.0",
34
34
  "events": "^3.3.0"
35
35
  },
36
36
  "devDependencies": {
package/vapi.ts CHANGED
@@ -216,11 +216,13 @@ export default class Vapi extends VapiEventEmitter {
216
216
  this.dailyCallObject = createSafeDailyFactoryOptions(dailyCallObject);
217
217
  }
218
218
 
219
- private cleanup() {
219
+ private async cleanup() {
220
220
  this.started = false;
221
221
  this.hasEmittedCallEndedStatus = false;
222
- this.call?.destroy();
223
- this.call = null;
222
+ if (this.call) {
223
+ await this.call.destroy();
224
+ this.call = null;
225
+ }
224
226
  this.speakingTimeout = null;
225
227
  }
226
228
 
@@ -325,7 +327,7 @@ export default class Vapi extends VapiEventEmitter {
325
327
  timestamp: new Date().toISOString(),
326
328
  metadata: { action: 'cleanup-existing' }
327
329
  });
328
- this.cleanup();
330
+ await this.cleanup();
329
331
  }
330
332
 
331
333
  const isVideoRecordingEnabled =
@@ -395,7 +397,7 @@ export default class Vapi extends VapiEventEmitter {
395
397
  if (isVideoRecordingEnabled) {
396
398
  this.call?.stopRecording();
397
399
  }
398
- this.cleanup();
400
+ this.cleanup().catch(console.error);
399
401
  });
400
402
 
401
403
  this.call.on('error', (error: any) => {
@@ -743,7 +745,7 @@ export default class Vapi extends VapiEventEmitter {
743
745
  }
744
746
  });
745
747
 
746
- this.cleanup();
748
+ await this.cleanup();
747
749
  return null;
748
750
  }
749
751
  }
@@ -800,10 +802,13 @@ export default class Vapi extends VapiEventEmitter {
800
802
  }, 1000);
801
803
  }
802
804
 
803
- stop(): void {
805
+ async stop(): Promise<void> {
804
806
  this.started = false;
805
- this.call?.destroy();
806
- this.call = null;
807
+ if (this.call) {
808
+ await this.call.destroy();
809
+ this.call = null;
810
+ }
811
+ this.speakingTimeout = null;
807
812
  }
808
813
 
809
814
  send(message: VapiClientToServerMessage): void {