@vapi-ai/web 2.3.10 → 2.5.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
@@ -2,6 +2,9 @@ import type { ChatCompletionMessageParam } from 'openai/resources';
2
2
  import { DailyCall, DailyAdvancedConfig, DailyFactoryOptions, DailyParticipant, DailyVideoSendSettings } from '@daily-co/daily-js';
3
3
  import EventEmitter from 'events';
4
4
  import { Call, CreateSquadDTO, CreateAssistantDTO, AssistantOverrides, CreateWorkflowDTO, WorkflowOverrides } from './api';
5
+ export interface EndCallMessage {
6
+ type: 'end-call';
7
+ }
5
8
  export interface AddMessageMessage {
6
9
  type: 'add-message';
7
10
  message: ChatCompletionMessageParam;
@@ -19,7 +22,7 @@ export interface SayMessage {
19
22
  interruptionsEnabled?: boolean;
20
23
  interruptAssistantEnabled?: boolean;
21
24
  }
22
- type VapiClientToServerMessage = AddMessageMessage | ControlMessages | SayMessage;
25
+ type VapiClientToServerMessage = AddMessageMessage | ControlMessages | SayMessage | EndCallMessage;
23
26
  type VapiEventNames = 'call-end' | 'call-start' | 'volume-level' | 'speech-start' | 'speech-end' | 'message' | 'video' | 'error' | 'camera-error' | 'network-quality-change' | 'network-connection' | 'daily-participant-updated' | 'call-start-progress' | 'call-start-success' | 'call-start-failed';
24
27
  interface CallStartProgressEvent {
25
28
  stage: string;
@@ -58,6 +61,47 @@ type VapiEventListeners = {
58
61
  'call-start-success': (event: CallStartSuccessEvent) => void;
59
62
  'call-start-failed': (event: CallStartFailedEvent) => void;
60
63
  };
64
+ type StartCallOptions = {
65
+ /**
66
+ * This determines whether the daily room will be deleted and all participants will be kicked once the user leaves the room.
67
+ * If set to `false`, the room will be kept alive even after the user leaves, allowing clients to reconnect to the same room.
68
+ * If set to `true`, the room will be deleted and reconnection will not be allowed.
69
+ *
70
+ * Defaults to `true`.
71
+ * @example true
72
+ */
73
+ roomDeleteOnUserLeaveEnabled?: boolean;
74
+ };
75
+ type WebCall = {
76
+ /**
77
+ * The Vapi WebCall URL. This is the URL that the call will be joined on.
78
+ *
79
+ * call.webCallUrl or call.transport.callUrl
80
+ */
81
+ webCallUrl: string;
82
+ /**
83
+ * The Vapi WebCall ID. This is the ID of the call.
84
+ *
85
+ * call.id
86
+ */
87
+ id?: string;
88
+ /**
89
+ * The Vapi WebCall artifact plan. This is the artifact plan of the call.
90
+ */
91
+ artifactPlan?: {
92
+ videoRecordingEnabled?: boolean;
93
+ };
94
+ /**
95
+ * The Vapi WebCall assistant. This is the assistant of the call.
96
+ *
97
+ * call.assistant
98
+ */
99
+ assistant?: {
100
+ voice?: {
101
+ provider?: string;
102
+ };
103
+ };
104
+ };
61
105
  declare class VapiEventEmitter extends EventEmitter {
62
106
  on<E extends VapiEventNames>(event: E, listener: VapiEventListeners[E]): this;
63
107
  once<E extends VapiEventNames>(event: E, listener: VapiEventListeners[E]): this;
@@ -76,19 +120,43 @@ export default class Vapi extends VapiEventEmitter {
76
120
  private cleanup;
77
121
  private isMobileDevice;
78
122
  private sleep;
79
- start(assistant?: CreateAssistantDTO | string, assistantOverrides?: AssistantOverrides, squad?: CreateSquadDTO | string, workflow?: CreateWorkflowDTO | string, workflowOverrides?: WorkflowOverrides): Promise<Call | null>;
123
+ start(assistant?: CreateAssistantDTO | string, assistantOverrides?: AssistantOverrides, squad?: CreateSquadDTO | string, workflow?: CreateWorkflowDTO | string, workflowOverrides?: WorkflowOverrides, options?: StartCallOptions): Promise<Call | null>;
80
124
  private onAppMessage;
81
125
  private handleRemoteParticipantsAudioLevel;
82
- stop(): void;
126
+ /**
127
+ * Stops the call by destroying the Daily call object.
128
+ *
129
+ * If `roomDeleteOnUserLeaveEnabled` is set to `false`, the Vapi call will be kept alive, allowing reconnections to the same call using the `reconnect` method.
130
+ * If `roomDeleteOnUserLeaveEnabled` is set to `true`, the Vapi call will also be destroyed, preventing any reconnections.
131
+ */
132
+ stop(): Promise<void>;
133
+ /**
134
+ * Sends a Live Call Control message to the Vapi server.
135
+ *
136
+ * Docs: https://docs.vapi.ai/calls/call-features
137
+ */
83
138
  send(message: VapiClientToServerMessage): void;
84
139
  setMuted(mute: boolean): void;
85
140
  isMuted(): boolean;
86
141
  say(message: string, endCallAfterSpoken?: boolean, interruptionsEnabled?: boolean, interruptAssistantEnabled?: boolean): void;
142
+ /**
143
+ * Ends the call immediately by sending a `end-call` message using Live Call Control, and destroys the Daily call object.
144
+ *
145
+ * This method always ends the call, regardless of the `roomDeleteOnUserLeaveEnabled` option.
146
+ */
147
+ end(): void;
87
148
  setInputDevicesAsync(options: Parameters<DailyCall['setInputDevicesAsync']>[0]): Promise<void>;
88
149
  increaseMicLevel(gain: number): Promise<void>;
89
150
  setOutputDeviceAsync(options: Parameters<DailyCall['setOutputDeviceAsync']>[0]): void;
90
151
  getDailyCallObject(): DailyCall | null;
91
152
  startScreenSharing(displayMediaOptions?: DisplayMediaStreamOptions, screenVideoSendSettings?: DailyVideoSendSettings): void;
92
153
  stopScreenSharing(): void;
154
+ /**
155
+ * Reconnects to an active call.
156
+ *
157
+ *
158
+ * @param webCall
159
+ */
160
+ reconnect(webCall: WebCall): Promise<void>;
93
161
  }
94
162
  export {};