@vapi-ai/web 2.5.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/api.ts +4566 -1361
- package/dist/api.d.ts +3460 -910
- package/dist/api.js +259 -68
- package/dist/vapi.d.ts +21 -0
- package/dist/vapi.js +120 -0
- package/package.json +2 -2
- package/vapi.ts +125 -0
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
|
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
|
@@ -158,5 +158,26 @@ export default class Vapi extends VapiEventEmitter {
|
|
|
158
158
|
* @param webCall
|
|
159
159
|
*/
|
|
160
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>>;
|
|
161
182
|
}
|
|
162
183
|
export {};
|
package/dist/vapi.js
CHANGED
|
@@ -1042,5 +1042,125 @@ class Vapi extends VapiEventEmitter {
|
|
|
1042
1042
|
throw e;
|
|
1043
1043
|
}
|
|
1044
1044
|
}
|
|
1045
|
+
/**
|
|
1046
|
+
* Runs all network connectivity tests for pre-call diagnostics.
|
|
1047
|
+
* Creates a temporary Daily call object for testing purposes.
|
|
1048
|
+
*
|
|
1049
|
+
* Tests performed:
|
|
1050
|
+
* 1. Network connectivity (TURN server) - Tests if traffic can be relayed through TURN servers
|
|
1051
|
+
* 2. Websocket connectivity - Tests if websocket connections can be established
|
|
1052
|
+
* 3. Call quality - Tests overall call quality metrics (if available in SDK version)
|
|
1053
|
+
*
|
|
1054
|
+
* @returns {Promise<Record<string, any>>} Test results object with status for each test
|
|
1055
|
+
*
|
|
1056
|
+
* @example
|
|
1057
|
+
* // Run pre-call network diagnostics
|
|
1058
|
+
* const results = await Vapi.runNetworkTestsStandalone();
|
|
1059
|
+
* if (results.networkConnectivity?.result === 'failed') {
|
|
1060
|
+
* console.warn('Network issues detected - calls may not work properly');
|
|
1061
|
+
* }
|
|
1062
|
+
*
|
|
1063
|
+
* @static
|
|
1064
|
+
*/
|
|
1065
|
+
static async runNetworkTestsStandalone() {
|
|
1066
|
+
console.log('Starting standalone network connectivity tests...');
|
|
1067
|
+
const results = {};
|
|
1068
|
+
let tempCall = null;
|
|
1069
|
+
try {
|
|
1070
|
+
// Create a temporary call object for testing
|
|
1071
|
+
console.log('Creating temporary call object for testing...');
|
|
1072
|
+
tempCall = daily_js_1.default.createCallObject({
|
|
1073
|
+
audioSource: true,
|
|
1074
|
+
videoSource: true,
|
|
1075
|
+
});
|
|
1076
|
+
// Test 1: Network Connectivity (TURN server test)
|
|
1077
|
+
console.log('\n1. Testing network connectivity (TURN server)...');
|
|
1078
|
+
let videoTrack = null;
|
|
1079
|
+
try {
|
|
1080
|
+
// Create a dummy video track for the test
|
|
1081
|
+
const stream = await navigator.mediaDevices.getUserMedia({ video: true });
|
|
1082
|
+
videoTrack = stream.getVideoTracks()[0];
|
|
1083
|
+
const networkTest = await tempCall.testNetworkConnectivity(videoTrack);
|
|
1084
|
+
results.networkConnectivity = networkTest;
|
|
1085
|
+
console.log('Network connectivity test result:', networkTest);
|
|
1086
|
+
}
|
|
1087
|
+
catch (error) {
|
|
1088
|
+
results.networkConnectivity = { result: 'error', error: error?.toString() };
|
|
1089
|
+
console.error('Network connectivity test error:', error);
|
|
1090
|
+
}
|
|
1091
|
+
finally {
|
|
1092
|
+
// Clean up the video track
|
|
1093
|
+
if (videoTrack) {
|
|
1094
|
+
videoTrack.stop();
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
// Test 2: Websocket Connectivity
|
|
1098
|
+
console.log('\n2. Testing websocket connectivity...');
|
|
1099
|
+
try {
|
|
1100
|
+
const websocketTest = await tempCall.testWebsocketConnectivity();
|
|
1101
|
+
results.websocketConnectivity = websocketTest;
|
|
1102
|
+
console.log('Websocket connectivity test result:', websocketTest);
|
|
1103
|
+
}
|
|
1104
|
+
catch (error) {
|
|
1105
|
+
results.websocketConnectivity = { result: 'error', error: error?.toString() };
|
|
1106
|
+
console.error('Websocket connectivity test error:', error);
|
|
1107
|
+
}
|
|
1108
|
+
// Test 3: Call Quality (if available)
|
|
1109
|
+
console.log('\n3. Testing call quality...');
|
|
1110
|
+
try {
|
|
1111
|
+
// Check if the method exists
|
|
1112
|
+
if (typeof tempCall.testCallQuality === 'function') {
|
|
1113
|
+
// Call quality test requires startCamera to initialize call state
|
|
1114
|
+
try {
|
|
1115
|
+
// Use startCamera to initialize the call state without needing a room
|
|
1116
|
+
console.log('Initializing call state with startCamera...');
|
|
1117
|
+
await tempCall.startCamera();
|
|
1118
|
+
// Now run the call quality test
|
|
1119
|
+
const callQualityTest = await tempCall.testCallQuality();
|
|
1120
|
+
results.callQuality = callQualityTest;
|
|
1121
|
+
console.log('Call quality test result:', callQualityTest);
|
|
1122
|
+
// Camera will be cleaned up when we destroy the call object
|
|
1123
|
+
}
|
|
1124
|
+
catch (startCameraError) {
|
|
1125
|
+
// If startCamera fails, it might be due to permissions or other issues
|
|
1126
|
+
console.error('Failed to start camera for call quality test:', startCameraError);
|
|
1127
|
+
results.callQuality = {
|
|
1128
|
+
result: 'error',
|
|
1129
|
+
error: startCameraError?.toString(),
|
|
1130
|
+
message: 'Failed to initialize camera for call quality test. Check camera permissions.'
|
|
1131
|
+
};
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
else {
|
|
1135
|
+
results.callQuality = { result: 'not-available', message: 'testCallQuality method not available' };
|
|
1136
|
+
console.log('Call quality test not available in current Daily.co version');
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
catch (error) {
|
|
1140
|
+
results.callQuality = { result: 'error', error: error?.toString() };
|
|
1141
|
+
console.error('Call quality test error:', error);
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
catch (error) {
|
|
1145
|
+
console.error('Failed to create temporary call object:', error);
|
|
1146
|
+
results.error = error?.toString();
|
|
1147
|
+
}
|
|
1148
|
+
finally {
|
|
1149
|
+
// Clean up the temporary call object
|
|
1150
|
+
if (tempCall) {
|
|
1151
|
+
try {
|
|
1152
|
+
console.log('Cleaning up temporary call object...');
|
|
1153
|
+
await tempCall.destroy();
|
|
1154
|
+
}
|
|
1155
|
+
catch (error) {
|
|
1156
|
+
console.error('Error destroying temporary call object:', error);
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
// Summary
|
|
1161
|
+
console.log('\n=== Network Test Summary ===');
|
|
1162
|
+
console.log('Results:', JSON.stringify(results, null, 2));
|
|
1163
|
+
return results;
|
|
1164
|
+
}
|
|
1045
1165
|
}
|
|
1046
1166
|
exports.default = Vapi;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vapi-ai/web",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/vapi.js",
|
|
6
6
|
"types": "dist/vapi.d.ts",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"node": ">=18.0.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@daily-co/daily-js": "^0.
|
|
34
|
+
"@daily-co/daily-js": "^0.85.0",
|
|
35
35
|
"events": "^3.3.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
package/vapi.ts
CHANGED
|
@@ -1365,4 +1365,129 @@ export default class Vapi extends VapiEventEmitter {
|
|
|
1365
1365
|
throw e;
|
|
1366
1366
|
}
|
|
1367
1367
|
}
|
|
1368
|
+
|
|
1369
|
+
/**
|
|
1370
|
+
* Runs all network connectivity tests for pre-call diagnostics.
|
|
1371
|
+
* Creates a temporary Daily call object for testing purposes.
|
|
1372
|
+
*
|
|
1373
|
+
* Tests performed:
|
|
1374
|
+
* 1. Network connectivity (TURN server) - Tests if traffic can be relayed through TURN servers
|
|
1375
|
+
* 2. Websocket connectivity - Tests if websocket connections can be established
|
|
1376
|
+
* 3. Call quality - Tests overall call quality metrics (if available in SDK version)
|
|
1377
|
+
*
|
|
1378
|
+
* @returns {Promise<Record<string, any>>} Test results object with status for each test
|
|
1379
|
+
*
|
|
1380
|
+
* @example
|
|
1381
|
+
* // Run pre-call network diagnostics
|
|
1382
|
+
* const results = await Vapi.runNetworkTestsStandalone();
|
|
1383
|
+
* if (results.networkConnectivity?.result === 'failed') {
|
|
1384
|
+
* console.warn('Network issues detected - calls may not work properly');
|
|
1385
|
+
* }
|
|
1386
|
+
*
|
|
1387
|
+
* @static
|
|
1388
|
+
*/
|
|
1389
|
+
public static async runNetworkTestsStandalone(): Promise<Record<string, any>> {
|
|
1390
|
+
console.log('Starting standalone network connectivity tests...');
|
|
1391
|
+
|
|
1392
|
+
const results: Record<string, any> = {};
|
|
1393
|
+
let tempCall: DailyCall | null = null;
|
|
1394
|
+
|
|
1395
|
+
try {
|
|
1396
|
+
// Create a temporary call object for testing
|
|
1397
|
+
console.log('Creating temporary call object for testing...');
|
|
1398
|
+
tempCall = DailyIframe.createCallObject({
|
|
1399
|
+
audioSource: true,
|
|
1400
|
+
videoSource: true,
|
|
1401
|
+
});
|
|
1402
|
+
|
|
1403
|
+
// Test 1: Network Connectivity (TURN server test)
|
|
1404
|
+
console.log('\n1. Testing network connectivity (TURN server)...');
|
|
1405
|
+
let videoTrack: MediaStreamTrack | null = null;
|
|
1406
|
+
|
|
1407
|
+
try {
|
|
1408
|
+
// Create a dummy video track for the test
|
|
1409
|
+
const stream = await navigator.mediaDevices.getUserMedia({ video: true });
|
|
1410
|
+
videoTrack = stream.getVideoTracks()[0];
|
|
1411
|
+
|
|
1412
|
+
const networkTest = await tempCall.testNetworkConnectivity(videoTrack);
|
|
1413
|
+
results.networkConnectivity = networkTest;
|
|
1414
|
+
console.log('Network connectivity test result:', networkTest);
|
|
1415
|
+
} catch (error) {
|
|
1416
|
+
results.networkConnectivity = { result: 'error', error: error?.toString() };
|
|
1417
|
+
console.error('Network connectivity test error:', error);
|
|
1418
|
+
} finally {
|
|
1419
|
+
// Clean up the video track
|
|
1420
|
+
if (videoTrack) {
|
|
1421
|
+
videoTrack.stop();
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
// Test 2: Websocket Connectivity
|
|
1426
|
+
console.log('\n2. Testing websocket connectivity...');
|
|
1427
|
+
try {
|
|
1428
|
+
const websocketTest = await tempCall.testWebsocketConnectivity();
|
|
1429
|
+
results.websocketConnectivity = websocketTest;
|
|
1430
|
+
console.log('Websocket connectivity test result:', websocketTest);
|
|
1431
|
+
} catch (error) {
|
|
1432
|
+
results.websocketConnectivity = { result: 'error', error: error?.toString() };
|
|
1433
|
+
console.error('Websocket connectivity test error:', error);
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
// Test 3: Call Quality (if available)
|
|
1437
|
+
console.log('\n3. Testing call quality...');
|
|
1438
|
+
try {
|
|
1439
|
+
// Check if the method exists
|
|
1440
|
+
if (typeof tempCall.testCallQuality === 'function') {
|
|
1441
|
+
// Call quality test requires startCamera to initialize call state
|
|
1442
|
+
try {
|
|
1443
|
+
// Use startCamera to initialize the call state without needing a room
|
|
1444
|
+
console.log('Initializing call state with startCamera...');
|
|
1445
|
+
await tempCall.startCamera();
|
|
1446
|
+
|
|
1447
|
+
// Now run the call quality test
|
|
1448
|
+
const callQualityTest = await tempCall.testCallQuality();
|
|
1449
|
+
results.callQuality = callQualityTest;
|
|
1450
|
+
console.log('Call quality test result:', callQualityTest);
|
|
1451
|
+
|
|
1452
|
+
// Camera will be cleaned up when we destroy the call object
|
|
1453
|
+
} catch (startCameraError: any) {
|
|
1454
|
+
// If startCamera fails, it might be due to permissions or other issues
|
|
1455
|
+
console.error('Failed to start camera for call quality test:', startCameraError);
|
|
1456
|
+
results.callQuality = {
|
|
1457
|
+
result: 'error',
|
|
1458
|
+
error: startCameraError?.toString(),
|
|
1459
|
+
message: 'Failed to initialize camera for call quality test. Check camera permissions.'
|
|
1460
|
+
};
|
|
1461
|
+
}
|
|
1462
|
+
} else {
|
|
1463
|
+
results.callQuality = { result: 'not-available', message: 'testCallQuality method not available' };
|
|
1464
|
+
console.log('Call quality test not available in current Daily.co version');
|
|
1465
|
+
}
|
|
1466
|
+
} catch (error: any) {
|
|
1467
|
+
results.callQuality = { result: 'error', error: error?.toString() };
|
|
1468
|
+
console.error('Call quality test error:', error);
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
} catch (error) {
|
|
1472
|
+
console.error('Failed to create temporary call object:', error);
|
|
1473
|
+
results.error = error?.toString();
|
|
1474
|
+
} finally {
|
|
1475
|
+
// Clean up the temporary call object
|
|
1476
|
+
if (tempCall) {
|
|
1477
|
+
try {
|
|
1478
|
+
console.log('Cleaning up temporary call object...');
|
|
1479
|
+
await tempCall.destroy();
|
|
1480
|
+
} catch (error) {
|
|
1481
|
+
console.error('Error destroying temporary call object:', error);
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
// Summary
|
|
1487
|
+
console.log('\n=== Network Test Summary ===');
|
|
1488
|
+
console.log('Results:', JSON.stringify(results, null, 2));
|
|
1489
|
+
|
|
1490
|
+
return results;
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1368
1493
|
}
|