@vapi-ai/web 2.4.0 → 2.5.1

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
@@ -72,20 +72,15 @@ class HttpClient {
72
72
  [ContentType.Text]: (input) => input !== null && typeof input !== "string"
73
73
  ? JSON.stringify(input)
74
74
  : input,
75
- [ContentType.FormData]: (input) => {
76
- if (input instanceof FormData) {
77
- return input;
78
- }
79
- return Object.keys(input || {}).reduce((formData, key) => {
80
- const property = input[key];
81
- formData.append(key, property instanceof Blob
82
- ? property
83
- : typeof property === "object" && property !== null
84
- ? JSON.stringify(property)
85
- : `${property}`);
86
- return formData;
87
- }, new FormData());
88
- },
75
+ [ContentType.FormData]: (input) => Object.keys(input || {}).reduce((formData, key) => {
76
+ const property = input[key];
77
+ formData.append(key, property instanceof Blob
78
+ ? property
79
+ : typeof property === "object" && property !== null
80
+ ? JSON.stringify(property)
81
+ : `${property}`);
82
+ return formData;
83
+ }, new FormData()),
89
84
  [ContentType.UrlEncoded]: (input) => this.toQueryString(input),
90
85
  };
91
86
  mergeRequestParams(params1, params2) {
@@ -143,13 +138,12 @@ class HttpClient {
143
138
  ? null
144
139
  : payloadFormatter(body),
145
140
  }).then(async (response) => {
146
- const r = response;
141
+ const r = response.clone();
147
142
  r.data = null;
148
143
  r.error = null;
149
- const responseToParse = responseFormat ? response.clone() : response;
150
144
  const data = !responseFormat
151
145
  ? r
152
- : await responseToParse[responseFormat]()
146
+ : await response[responseFormat]()
153
147
  .then((data) => {
154
148
  if (r.ok) {
155
149
  r.data = data;
@@ -642,10 +636,12 @@ class Api extends HttpClient {
642
636
  * @request DELETE:/call/{id}
643
637
  * @secure
644
638
  */
645
- callControllerDeleteCallData: (id, params = {}) => this.request({
639
+ callControllerDeleteCallData: (id, data, params = {}) => this.request({
646
640
  path: `/call/${id}`,
647
641
  method: "DELETE",
642
+ body: data,
648
643
  secure: true,
644
+ type: ContentType.Json,
649
645
  format: "json",
650
646
  ...params,
651
647
  }),
@@ -1475,6 +1471,41 @@ class Api extends HttpClient {
1475
1471
  format: "json",
1476
1472
  ...params,
1477
1473
  }),
1474
+ /**
1475
+ * No description
1476
+ *
1477
+ * @tags Structured Outputs
1478
+ * @name StructuredOutputControllerRun
1479
+ * @summary Run Structured Output
1480
+ * @request POST:/structured-output/run
1481
+ * @secure
1482
+ */
1483
+ structuredOutputControllerRun: (data, params = {}) => this.request({
1484
+ path: `/structured-output/run`,
1485
+ method: "POST",
1486
+ body: data,
1487
+ secure: true,
1488
+ type: ContentType.Json,
1489
+ format: "json",
1490
+ ...params,
1491
+ }),
1492
+ /**
1493
+ * @description Analyzes assistant configuration and generates contextual structured output recommendations
1494
+ *
1495
+ * @tags Structured Outputs
1496
+ * @name StructuredOutputControllerSuggest
1497
+ * @summary Generate AI-Powered Structured Output Suggestions
1498
+ * @request POST:/structured-output/suggest
1499
+ * @secure
1500
+ */
1501
+ structuredOutputControllerSuggest: (data, params = {}) => this.request({
1502
+ path: `/structured-output/suggest`,
1503
+ method: "POST",
1504
+ body: data,
1505
+ secure: true,
1506
+ type: ContentType.Json,
1507
+ ...params,
1508
+ }),
1478
1509
  };
1479
1510
  testSuite = {
1480
1511
  /**
@@ -1733,6 +1764,129 @@ class Api extends HttpClient {
1733
1764
  ...params,
1734
1765
  }),
1735
1766
  };
1767
+ reporting = {
1768
+ /**
1769
+ * No description
1770
+ *
1771
+ * @tags Insight
1772
+ * @name InsightControllerCreate
1773
+ * @summary Create Insight
1774
+ * @request POST:/reporting/insight
1775
+ * @secure
1776
+ */
1777
+ insightControllerCreate: (data, params = {}) => this.request({
1778
+ path: `/reporting/insight`,
1779
+ method: "POST",
1780
+ body: data,
1781
+ secure: true,
1782
+ type: ContentType.Json,
1783
+ format: "json",
1784
+ ...params,
1785
+ }),
1786
+ /**
1787
+ * No description
1788
+ *
1789
+ * @tags Insight
1790
+ * @name InsightControllerFindAll
1791
+ * @summary Get Insights
1792
+ * @request GET:/reporting/insight
1793
+ * @secure
1794
+ */
1795
+ insightControllerFindAll: (query, params = {}) => this.request({
1796
+ path: `/reporting/insight`,
1797
+ method: "GET",
1798
+ query: query,
1799
+ secure: true,
1800
+ format: "json",
1801
+ ...params,
1802
+ }),
1803
+ /**
1804
+ * No description
1805
+ *
1806
+ * @tags Insight
1807
+ * @name InsightControllerUpdate
1808
+ * @summary Update Insight
1809
+ * @request PATCH:/reporting/insight/{id}
1810
+ * @secure
1811
+ */
1812
+ insightControllerUpdate: (id, data, params = {}) => this.request({
1813
+ path: `/reporting/insight/${id}`,
1814
+ method: "PATCH",
1815
+ body: data,
1816
+ secure: true,
1817
+ type: ContentType.Json,
1818
+ format: "json",
1819
+ ...params,
1820
+ }),
1821
+ /**
1822
+ * No description
1823
+ *
1824
+ * @tags Insight
1825
+ * @name InsightControllerFindOne
1826
+ * @summary Get Insight
1827
+ * @request GET:/reporting/insight/{id}
1828
+ * @secure
1829
+ */
1830
+ insightControllerFindOne: (id, params = {}) => this.request({
1831
+ path: `/reporting/insight/${id}`,
1832
+ method: "GET",
1833
+ secure: true,
1834
+ format: "json",
1835
+ ...params,
1836
+ }),
1837
+ /**
1838
+ * No description
1839
+ *
1840
+ * @tags Insight
1841
+ * @name InsightControllerRemove
1842
+ * @summary Delete Insight
1843
+ * @request DELETE:/reporting/insight/{id}
1844
+ * @secure
1845
+ */
1846
+ insightControllerRemove: (id, params = {}) => this.request({
1847
+ path: `/reporting/insight/${id}`,
1848
+ method: "DELETE",
1849
+ secure: true,
1850
+ format: "json",
1851
+ ...params,
1852
+ }),
1853
+ /**
1854
+ * No description
1855
+ *
1856
+ * @tags Insight
1857
+ * @name InsightControllerRun
1858
+ * @summary Run Insight
1859
+ * @request POST:/reporting/insight/{id}/run
1860
+ * @secure
1861
+ */
1862
+ insightControllerRun: (id, data, params = {}) => this.request({
1863
+ path: `/reporting/insight/${id}/run`,
1864
+ method: "POST",
1865
+ body: data,
1866
+ secure: true,
1867
+ type: ContentType.Json,
1868
+ format: "json",
1869
+ ...params,
1870
+ }),
1871
+ /**
1872
+ * No description
1873
+ *
1874
+ * @tags Insight
1875
+ * @name InsightControllerPreview
1876
+ * @summary Preview Insight
1877
+ * @request POST:/reporting/insight/preview
1878
+ * @secure
1879
+ */
1880
+ insightControllerPreview: (data, params = {}) => this.request({
1881
+ path: `/reporting/insight/preview`,
1882
+ method: "POST",
1883
+ body: data,
1884
+ secure: true,
1885
+ type: ContentType.Json,
1886
+ format: "json",
1887
+ ...params,
1888
+ }),
1889
+ };
1736
1890
  eval = {
1737
1891
  /**
1738
1892
  * No description
@@ -1886,6 +2040,93 @@ class Api extends HttpClient {
1886
2040
  ...params,
1887
2041
  }),
1888
2042
  };
2043
+ observability = {
2044
+ /**
2045
+ * No description
2046
+ *
2047
+ * @tags Observability/Scorecard
2048
+ * @name ScorecardControllerGet
2049
+ * @summary Get Scorecard
2050
+ * @request GET:/observability/scorecard/{id}
2051
+ * @secure
2052
+ */
2053
+ scorecardControllerGet: (id, params = {}) => this.request({
2054
+ path: `/observability/scorecard/${id}`,
2055
+ method: "GET",
2056
+ secure: true,
2057
+ format: "json",
2058
+ ...params,
2059
+ }),
2060
+ /**
2061
+ * No description
2062
+ *
2063
+ * @tags Observability/Scorecard
2064
+ * @name ScorecardControllerUpdate
2065
+ * @summary Update Scorecard
2066
+ * @request PATCH:/observability/scorecard/{id}
2067
+ * @secure
2068
+ */
2069
+ scorecardControllerUpdate: (id, data, params = {}) => this.request({
2070
+ path: `/observability/scorecard/${id}`,
2071
+ method: "PATCH",
2072
+ body: data,
2073
+ secure: true,
2074
+ type: ContentType.Json,
2075
+ format: "json",
2076
+ ...params,
2077
+ }),
2078
+ /**
2079
+ * No description
2080
+ *
2081
+ * @tags Observability/Scorecard
2082
+ * @name ScorecardControllerRemove
2083
+ * @summary Delete Scorecard
2084
+ * @request DELETE:/observability/scorecard/{id}
2085
+ * @secure
2086
+ */
2087
+ scorecardControllerRemove: (id, params = {}) => this.request({
2088
+ path: `/observability/scorecard/${id}`,
2089
+ method: "DELETE",
2090
+ secure: true,
2091
+ format: "json",
2092
+ ...params,
2093
+ }),
2094
+ /**
2095
+ * No description
2096
+ *
2097
+ * @tags Observability/Scorecard
2098
+ * @name ScorecardControllerGetPaginated
2099
+ * @summary List Scorecards
2100
+ * @request GET:/observability/scorecard
2101
+ * @secure
2102
+ */
2103
+ scorecardControllerGetPaginated: (query, params = {}) => this.request({
2104
+ path: `/observability/scorecard`,
2105
+ method: "GET",
2106
+ query: query,
2107
+ secure: true,
2108
+ format: "json",
2109
+ ...params,
2110
+ }),
2111
+ /**
2112
+ * No description
2113
+ *
2114
+ * @tags Observability/Scorecard
2115
+ * @name ScorecardControllerCreate
2116
+ * @summary Create Scorecard
2117
+ * @request POST:/observability/scorecard
2118
+ * @secure
2119
+ */
2120
+ scorecardControllerCreate: (data, params = {}) => this.request({
2121
+ path: `/observability/scorecard`,
2122
+ method: "POST",
2123
+ body: data,
2124
+ secure: true,
2125
+ type: ContentType.Json,
2126
+ format: "json",
2127
+ ...params,
2128
+ }),
2129
+ };
1889
2130
  org = {
1890
2131
  /**
1891
2132
  * No description
@@ -2257,56 +2498,6 @@ class Api extends HttpClient {
2257
2498
  format: "json",
2258
2499
  ...params,
2259
2500
  }),
2260
- /**
2261
- * No description
2262
- *
2263
- * @tags Credentials
2264
- * @name CredentialControllerGenerateSession
2265
- * @summary Generate a credential session
2266
- * @request POST:/credential/session
2267
- * @secure
2268
- */
2269
- credentialControllerGenerateSession: (data, params = {}) => this.request({
2270
- path: `/credential/session`,
2271
- method: "POST",
2272
- body: data,
2273
- secure: true,
2274
- type: ContentType.Json,
2275
- format: "json",
2276
- ...params,
2277
- }),
2278
- /**
2279
- * No description
2280
- *
2281
- * @tags Credentials
2282
- * @name CredentialControllerHandleWebhook
2283
- * @summary Handle credential webhook
2284
- * @request POST:/credential/webhook
2285
- */
2286
- credentialControllerHandleWebhook: (data, params = {}) => this.request({
2287
- path: `/credential/webhook`,
2288
- method: "POST",
2289
- body: data,
2290
- type: ContentType.Json,
2291
- ...params,
2292
- }),
2293
- /**
2294
- * No description
2295
- *
2296
- * @tags Credentials
2297
- * @name CredentialControllerTriggerCredentialAction
2298
- * @summary Trigger a credential action
2299
- * @request POST:/credential/trigger
2300
- * @secure
2301
- */
2302
- credentialControllerTriggerCredentialAction: (data, params = {}) => this.request({
2303
- path: `/credential/trigger`,
2304
- method: "POST",
2305
- body: data,
2306
- secure: true,
2307
- type: ContentType.Json,
2308
- ...params,
2309
- }),
2310
2501
  };
2311
2502
  template = {
2312
2503
  /**
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,64 @@ 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;
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
+ */
82
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>;
161
+ /**
162
+ * Runs all network connectivity tests for pre-call diagnostics.
163
+ * Creates a temporary Daily call object for testing purposes.
164
+ *
165
+ * Tests performed:
166
+ * 1. Network connectivity (TURN server) - Tests if traffic can be relayed through TURN servers
167
+ * 2. Websocket connectivity - Tests if websocket connections can be established
168
+ * 3. Call quality - Tests overall call quality metrics (if available in SDK version)
169
+ *
170
+ * @returns {Promise<Record<string, any>>} Test results object with status for each test
171
+ *
172
+ * @example
173
+ * // Run pre-call network diagnostics
174
+ * const results = await Vapi.runNetworkTestsStandalone();
175
+ * if (results.networkConnectivity?.result === 'failed') {
176
+ * console.warn('Network issues detected - calls may not work properly');
177
+ * }
178
+ *
179
+ * @static
180
+ */
181
+ static runNetworkTestsStandalone(): Promise<Record<string, any>>;
93
182
  }
94
183
  export {};