@hivegpt/hiveai-angular 0.0.567 → 0.0.569
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/bundles/hivegpt-hiveai-angular.umd.js +280 -43
- package/bundles/hivegpt-hiveai-angular.umd.js.map +1 -1
- package/bundles/hivegpt-hiveai-angular.umd.min.js +1 -1
- package/bundles/hivegpt-hiveai-angular.umd.min.js.map +1 -1
- package/esm2015/lib/components/bot.service.js +1 -1
- package/esm2015/lib/components/chat-drawer/chat-drawer.component.js +50 -16
- package/esm2015/lib/components/chatbot/chatbot.component.js +5 -3
- package/esm2015/lib/components/voice-agent/components/voice-agent-modal/voice-agent-modal.component.js +7 -4
- package/esm2015/lib/components/voice-agent/services/voice-agent.service.js +35 -8
- package/esm2015/lib/components/voice-agent/voice-modal-tokens.js +1 -1
- package/esm2015/lib/services/platform-token-refresh.service.js +173 -0
- package/esm2015/public-api.js +2 -1
- package/fesm2015/hivegpt-hiveai-angular.js +258 -30
- package/fesm2015/hivegpt-hiveai-angular.js.map +1 -1
- package/hivegpt-hiveai-angular.metadata.json +1 -1
- package/lib/components/bot.service.d.ts.map +1 -1
- package/lib/components/chat-drawer/chat-drawer.component.d.ts +7 -1
- package/lib/components/chat-drawer/chat-drawer.component.d.ts.map +1 -1
- package/lib/components/chatbot/chatbot.component.d.ts +2 -0
- package/lib/components/chatbot/chatbot.component.d.ts.map +1 -1
- package/lib/components/voice-agent/components/voice-agent-modal/voice-agent-modal.component.d.ts +1 -0
- package/lib/components/voice-agent/components/voice-agent-modal/voice-agent-modal.component.d.ts.map +1 -1
- package/lib/components/voice-agent/services/voice-agent.service.d.ts +8 -2
- package/lib/components/voice-agent/services/voice-agent.service.d.ts.map +1 -1
- package/lib/components/voice-agent/voice-modal-tokens.d.ts +2 -0
- package/lib/components/voice-agent/voice-modal-tokens.d.ts.map +1 -1
- package/lib/services/platform-token-refresh.service.d.ts +59 -0
- package/lib/services/platform-token-refresh.service.d.ts.map +1 -0
- package/package.json +1 -1
- package/public-api.d.ts +1 -0
- package/public-api.d.ts.map +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/cdk/overlay'), require('@angular/cdk/portal'), require('@angular/common/http'), require('@angular/core'), require('@angular/platform-browser'), require('rxjs'), require('rxjs/operators'), require('ngx-socket-io'), require('@angular/forms'), require('microsoft-cognitiveservices-speech-sdk'), require('marked'), require('@daily-co/daily-js'), require('@angular/
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@hivegpt/hiveai-angular', ['exports', '@angular/cdk/overlay', '@angular/cdk/portal', '@angular/common/http', '@angular/core', '@angular/platform-browser', 'rxjs', 'rxjs/operators', 'ngx-socket-io', '@angular/forms', 'microsoft-cognitiveservices-speech-sdk', 'marked', '@daily-co/daily-js', '@angular/
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.hivegpt = global.hivegpt || {}, global.hivegpt["hiveai-angular"] = {}), global.ng.cdk.overlay, global.ng.cdk.portal, global.ng.common.http, global.ng.core, global.ng.platformBrowser, global.rxjs, global.rxjs.operators, global.ngxSocketIo, global.ng.forms, global.SpeechSDK, global.marked, global.Daily, global.ng.
|
|
5
|
-
})(this, (function (exports, overlay, portal, i1, i0, platformBrowser, rxjs, operators, ngxSocketIo, forms, SpeechSDK, marked, Daily,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/cdk/overlay'), require('@angular/cdk/portal'), require('@angular/common/http'), require('@angular/core'), require('@angular/platform-browser'), require('rxjs'), require('rxjs/operators'), require('@angular/common'), require('ngx-socket-io'), require('@angular/forms'), require('microsoft-cognitiveservices-speech-sdk'), require('marked'), require('@daily-co/daily-js'), require('@angular/material/icon'), require('@angular/material/sidenav'), require('ngx-quill')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@hivegpt/hiveai-angular', ['exports', '@angular/cdk/overlay', '@angular/cdk/portal', '@angular/common/http', '@angular/core', '@angular/platform-browser', 'rxjs', 'rxjs/operators', '@angular/common', 'ngx-socket-io', '@angular/forms', 'microsoft-cognitiveservices-speech-sdk', 'marked', '@daily-co/daily-js', '@angular/material/icon', '@angular/material/sidenav', 'ngx-quill'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.hivegpt = global.hivegpt || {}, global.hivegpt["hiveai-angular"] = {}), global.ng.cdk.overlay, global.ng.cdk.portal, global.ng.common.http, global.ng.core, global.ng.platformBrowser, global.rxjs, global.rxjs.operators, global.ng.common, global.ngxSocketIo, global.ng.forms, global.SpeechSDK, global.marked, global.Daily, global.ng.material.icon, global.ng.material.sidenav, global.ngxQuill));
|
|
5
|
+
})(this, (function (exports, overlay, portal, i1, i0, platformBrowser, rxjs, operators, common, ngxSocketIo, forms, SpeechSDK, marked, Daily, icon, sidenav, ngxQuill) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -781,6 +781,175 @@
|
|
|
781
781
|
},] }
|
|
782
782
|
];
|
|
783
783
|
|
|
784
|
+
/**
|
|
785
|
+
* Default matches Pro-Events `AppConstants.authTokenKey` — same localStorage shape
|
|
786
|
+
* `{ accessToken, refreshToken, ... }` as JSON.
|
|
787
|
+
* Named factory (no arrow fn) so ngc metadata collection accepts it.
|
|
788
|
+
*/
|
|
789
|
+
function hiveGptAuthStorageKeyFactory() {
|
|
790
|
+
return 'authcc-aae1';
|
|
791
|
+
}
|
|
792
|
+
var HIVEGPT_AUTH_STORAGE_KEY = new i0.InjectionToken('HIVEGPT_AUTH_STORAGE_KEY', {
|
|
793
|
+
providedIn: 'root',
|
|
794
|
+
factory: hiveGptAuthStorageKeyFactory,
|
|
795
|
+
});
|
|
796
|
+
/**
|
|
797
|
+
* Proactive access-token refresh (JWT `exp`) + single-flight queue, aligned with
|
|
798
|
+
* Pro-Events `EventInterceptor` + `AuthService.refreshToken`.
|
|
799
|
+
*/
|
|
800
|
+
var PlatformTokenRefreshService = /** @class */ (function () {
|
|
801
|
+
function PlatformTokenRefreshService(http,
|
|
802
|
+
/** Use `Object` (not `object`) so ngc metadata collection accepts the parameter type. */
|
|
803
|
+
platformId,
|
|
804
|
+
/**
|
|
805
|
+
* Avoid `string | null` on the parameter — `|` is treated as unsupported expression in ngc metadata.
|
|
806
|
+
*/
|
|
807
|
+
authStorageKey) {
|
|
808
|
+
this.http = http;
|
|
809
|
+
this.platformId = platformId;
|
|
810
|
+
this.refreshTokenInProgress = false;
|
|
811
|
+
this.refreshTokenSubject = new rxjs.BehaviorSubject(null);
|
|
812
|
+
this.storageKey =
|
|
813
|
+
authStorageKey != null && authStorageKey !== ''
|
|
814
|
+
? authStorageKey
|
|
815
|
+
: 'authcc-aae1';
|
|
816
|
+
}
|
|
817
|
+
/** Read parsed auth blob from localStorage (same as host app). */
|
|
818
|
+
PlatformTokenRefreshService.prototype.readStoredAuth = function () {
|
|
819
|
+
if (!common.isPlatformBrowser(this.platformId)) {
|
|
820
|
+
return null;
|
|
821
|
+
}
|
|
822
|
+
try {
|
|
823
|
+
var raw = localStorage.getItem(this.storageKey);
|
|
824
|
+
if (!raw) {
|
|
825
|
+
return null;
|
|
826
|
+
}
|
|
827
|
+
return JSON.parse(raw);
|
|
828
|
+
}
|
|
829
|
+
catch (_a) {
|
|
830
|
+
return null;
|
|
831
|
+
}
|
|
832
|
+
};
|
|
833
|
+
PlatformTokenRefreshService.prototype.persistAuth = function (res) {
|
|
834
|
+
if (!common.isPlatformBrowser(this.platformId) || !res) {
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
try {
|
|
838
|
+
localStorage.setItem(this.storageKey, JSON.stringify(res));
|
|
839
|
+
}
|
|
840
|
+
catch (e) {
|
|
841
|
+
console.warn('[HiveGpt] Failed to persist auth tokens', e);
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
/**
|
|
845
|
+
* JWT `exp` check without @auth0/angular-jwt (keeps package lean).
|
|
846
|
+
* @param skewSeconds refresh slightly before actual expiry (clock skew).
|
|
847
|
+
*/
|
|
848
|
+
PlatformTokenRefreshService.prototype.isAccessTokenExpired = function (token, skewSeconds) {
|
|
849
|
+
if (skewSeconds === void 0) { skewSeconds = 60; }
|
|
850
|
+
if (!token || typeof token !== 'string') {
|
|
851
|
+
return true;
|
|
852
|
+
}
|
|
853
|
+
var expMs = this.getJwtExpirationMs(token);
|
|
854
|
+
if (expMs == null) {
|
|
855
|
+
return false;
|
|
856
|
+
}
|
|
857
|
+
return expMs - skewSeconds * 1000 < Date.now();
|
|
858
|
+
};
|
|
859
|
+
PlatformTokenRefreshService.prototype.getJwtExpirationMs = function (token) {
|
|
860
|
+
try {
|
|
861
|
+
var parts = token.split('.');
|
|
862
|
+
if (parts.length < 2) {
|
|
863
|
+
return null;
|
|
864
|
+
}
|
|
865
|
+
var payload = parts[1]
|
|
866
|
+
.replace(/-/g, '+')
|
|
867
|
+
.replace(/_/g, '/');
|
|
868
|
+
var padded = payload + '='.repeat((4 - (payload.length % 4)) % 4);
|
|
869
|
+
if (typeof atob === 'undefined') {
|
|
870
|
+
return null;
|
|
871
|
+
}
|
|
872
|
+
var json = JSON.parse(atob(padded));
|
|
873
|
+
if ((json === null || json === void 0 ? void 0 : json.exp) == null || typeof json.exp !== 'number') {
|
|
874
|
+
return null;
|
|
875
|
+
}
|
|
876
|
+
return json.exp * 1000;
|
|
877
|
+
}
|
|
878
|
+
catch (_a) {
|
|
879
|
+
return null;
|
|
880
|
+
}
|
|
881
|
+
};
|
|
882
|
+
/**
|
|
883
|
+
* Returns a valid access token: refreshes via `POST {usersApiBaseUrl}/user/tokenRefresh`
|
|
884
|
+
* when JWT is expired and a refresh token exists in storage.
|
|
885
|
+
*/
|
|
886
|
+
PlatformTokenRefreshService.prototype.ensureValidAccessToken = function (currentAccessToken, usersApiBaseUrl) {
|
|
887
|
+
var _this = this;
|
|
888
|
+
if (!common.isPlatformBrowser(this.platformId)) {
|
|
889
|
+
return rxjs.of({
|
|
890
|
+
accessToken: currentAccessToken !== null && currentAccessToken !== void 0 ? currentAccessToken : '',
|
|
891
|
+
refreshed: false,
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
var stored = this.readStoredAuth();
|
|
895
|
+
var access = (currentAccessToken && String(currentAccessToken).trim()) ||
|
|
896
|
+
(stored === null || stored === void 0 ? void 0 : stored.accessToken) ||
|
|
897
|
+
'';
|
|
898
|
+
var refresh = stored === null || stored === void 0 ? void 0 : stored.refreshToken;
|
|
899
|
+
if (access && !this.isAccessTokenExpired(access)) {
|
|
900
|
+
return rxjs.of({ accessToken: access, refreshed: false });
|
|
901
|
+
}
|
|
902
|
+
if (!refresh || typeof refresh !== 'string') {
|
|
903
|
+
return rxjs.of({ accessToken: access, refreshed: false });
|
|
904
|
+
}
|
|
905
|
+
var base = (usersApiBaseUrl || '').replace(/\/+$/, '');
|
|
906
|
+
if (!base) {
|
|
907
|
+
return rxjs.of({ accessToken: access, refreshed: false });
|
|
908
|
+
}
|
|
909
|
+
var url = base + "/user/tokenRefresh";
|
|
910
|
+
if (!this.refreshTokenInProgress) {
|
|
911
|
+
this.refreshTokenInProgress = true;
|
|
912
|
+
this.refreshTokenSubject.next(null);
|
|
913
|
+
return this.http
|
|
914
|
+
.post(url, { refreshToken: refresh })
|
|
915
|
+
.pipe(operators.switchMap(function (authResponse) {
|
|
916
|
+
_this.refreshTokenInProgress = false;
|
|
917
|
+
if (authResponse === null || authResponse === void 0 ? void 0 : authResponse.accessToken) {
|
|
918
|
+
_this.persistAuth(authResponse);
|
|
919
|
+
_this.refreshTokenSubject.next(authResponse.accessToken);
|
|
920
|
+
return rxjs.of({
|
|
921
|
+
accessToken: authResponse.accessToken,
|
|
922
|
+
refreshed: true,
|
|
923
|
+
authResponse: authResponse,
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
_this.refreshTokenSubject.next(null);
|
|
927
|
+
return rxjs.throwError(function () { return new Error('Token refresh returned no accessToken'); });
|
|
928
|
+
}), operators.catchError(function (err) {
|
|
929
|
+
_this.refreshTokenInProgress = false;
|
|
930
|
+
_this.refreshTokenSubject.next(null);
|
|
931
|
+
return rxjs.throwError(function () { return err; });
|
|
932
|
+
}));
|
|
933
|
+
}
|
|
934
|
+
return this.refreshTokenSubject.pipe(operators.filter(function (t) { return t != null && t !== ''; }), operators.take(1), operators.switchMap(function (token) { return rxjs.of({
|
|
935
|
+
accessToken: token,
|
|
936
|
+
refreshed: true,
|
|
937
|
+
}); }));
|
|
938
|
+
};
|
|
939
|
+
return PlatformTokenRefreshService;
|
|
940
|
+
}());
|
|
941
|
+
PlatformTokenRefreshService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function PlatformTokenRefreshService_Factory() { return new PlatformTokenRefreshService(i0__namespace.ɵɵinject(i1__namespace.HttpClient), i0__namespace.ɵɵinject(i0__namespace.PLATFORM_ID), i0__namespace.ɵɵinject(HIVEGPT_AUTH_STORAGE_KEY, 8)); }, token: PlatformTokenRefreshService, providedIn: "root" });
|
|
942
|
+
PlatformTokenRefreshService.decorators = [
|
|
943
|
+
{ type: i0.Injectable, args: [{
|
|
944
|
+
providedIn: 'root',
|
|
945
|
+
},] }
|
|
946
|
+
];
|
|
947
|
+
PlatformTokenRefreshService.ctorParameters = function () { return [
|
|
948
|
+
{ type: i1.HttpClient },
|
|
949
|
+
{ type: Object, decorators: [{ type: i0.Inject, args: [i0.PLATFORM_ID,] }] },
|
|
950
|
+
{ type: String, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [HIVEGPT_AUTH_STORAGE_KEY,] }] }
|
|
951
|
+
]; };
|
|
952
|
+
|
|
784
953
|
var formatHoursAndMinutes = function (date) {
|
|
785
954
|
var hours = date.getHours() % 12;
|
|
786
955
|
var minutes = date.getMinutes();
|
|
@@ -1604,11 +1773,15 @@
|
|
|
1604
1773
|
* - Uses Daily.js for all audio, mic, and real-time speaking detection
|
|
1605
1774
|
*/
|
|
1606
1775
|
var VoiceAgentService = /** @class */ (function () {
|
|
1607
|
-
function VoiceAgentService(audioAnalyzer, wsClient, dailyClient
|
|
1776
|
+
function VoiceAgentService(audioAnalyzer, wsClient, dailyClient, platformTokenRefresh,
|
|
1777
|
+
/** `Object` not `object` — ngc metadata collection rejects the `object` type in DI params. */
|
|
1778
|
+
platformId) {
|
|
1608
1779
|
var _this = this;
|
|
1609
1780
|
this.audioAnalyzer = audioAnalyzer;
|
|
1610
1781
|
this.wsClient = wsClient;
|
|
1611
1782
|
this.dailyClient = dailyClient;
|
|
1783
|
+
this.platformTokenRefresh = platformTokenRefresh;
|
|
1784
|
+
this.platformId = platformId;
|
|
1612
1785
|
this.callStateSubject = new rxjs.BehaviorSubject('idle');
|
|
1613
1786
|
this.statusTextSubject = new rxjs.BehaviorSubject('');
|
|
1614
1787
|
this.durationSubject = new rxjs.BehaviorSubject('00:00');
|
|
@@ -1650,9 +1823,9 @@
|
|
|
1650
1823
|
this.statusTextSubject.next('');
|
|
1651
1824
|
this.durationSubject.next('0:00');
|
|
1652
1825
|
};
|
|
1653
|
-
VoiceAgentService.prototype.connect = function (apiUrl, token, botId, conversationId, apiKey, eventToken, eventUrl, domainAuthority) {
|
|
1826
|
+
VoiceAgentService.prototype.connect = function (apiUrl, token, botId, conversationId, apiKey, eventToken, eventUrl, domainAuthority, usersApiUrl) {
|
|
1654
1827
|
return __awaiter(this, void 0, void 0, function () {
|
|
1655
|
-
var baseUrl, postUrl, headers, res, json, wsUrl, error_1;
|
|
1828
|
+
var accessToken, ensured, e_1, baseUrl, postUrl, headers, res, json, wsUrl, error_1;
|
|
1656
1829
|
var _this = this;
|
|
1657
1830
|
return __generator(this, function (_a) {
|
|
1658
1831
|
switch (_a.label) {
|
|
@@ -1663,14 +1836,34 @@
|
|
|
1663
1836
|
}
|
|
1664
1837
|
_a.label = 1;
|
|
1665
1838
|
case 1:
|
|
1666
|
-
_a.trys.push([1,
|
|
1839
|
+
_a.trys.push([1, 8, , 10]);
|
|
1667
1840
|
this.callStateSubject.next('connecting');
|
|
1668
1841
|
this.statusTextSubject.next('Connecting...');
|
|
1842
|
+
accessToken = token;
|
|
1843
|
+
if (!(usersApiUrl && common.isPlatformBrowser(this.platformId))) return [3 /*break*/, 5];
|
|
1844
|
+
_a.label = 2;
|
|
1845
|
+
case 2:
|
|
1846
|
+
_a.trys.push([2, 4, , 5]);
|
|
1847
|
+
return [4 /*yield*/, this.platformTokenRefresh
|
|
1848
|
+
.ensureValidAccessToken(token, usersApiUrl)
|
|
1849
|
+
.pipe(operators.take(1))
|
|
1850
|
+
.toPromise()];
|
|
1851
|
+
case 3:
|
|
1852
|
+
ensured = _a.sent();
|
|
1853
|
+
if (ensured === null || ensured === void 0 ? void 0 : ensured.accessToken) {
|
|
1854
|
+
accessToken = ensured.accessToken;
|
|
1855
|
+
}
|
|
1856
|
+
return [3 /*break*/, 5];
|
|
1857
|
+
case 4:
|
|
1858
|
+
e_1 = _a.sent();
|
|
1859
|
+
console.warn('[HiveGpt Voice] Token refresh before connect failed', e_1);
|
|
1860
|
+
return [3 /*break*/, 5];
|
|
1861
|
+
case 5:
|
|
1669
1862
|
baseUrl = apiUrl.replace(/\/$/, '');
|
|
1670
|
-
postUrl =
|
|
1863
|
+
postUrl = "https://1356-103-210-33-236.ngrok-free.app/ai/ask-voice";
|
|
1671
1864
|
headers = {
|
|
1672
1865
|
'Content-Type': 'application/json',
|
|
1673
|
-
Authorization: "Bearer " +
|
|
1866
|
+
Authorization: "Bearer " + accessToken,
|
|
1674
1867
|
'domain-authority': domainAuthority,
|
|
1675
1868
|
'eventtoken': eventToken,
|
|
1676
1869
|
'eventurl': eventUrl,
|
|
@@ -1687,13 +1880,13 @@
|
|
|
1687
1880
|
voice: 'alloy',
|
|
1688
1881
|
}),
|
|
1689
1882
|
})];
|
|
1690
|
-
case
|
|
1883
|
+
case 6:
|
|
1691
1884
|
res = _a.sent();
|
|
1692
1885
|
if (!res.ok) {
|
|
1693
1886
|
throw new Error("HTTP " + res.status);
|
|
1694
1887
|
}
|
|
1695
1888
|
return [4 /*yield*/, res.json()];
|
|
1696
|
-
case
|
|
1889
|
+
case 7:
|
|
1697
1890
|
json = _a.sent();
|
|
1698
1891
|
wsUrl = json === null || json === void 0 ? void 0 : json.rn_ws_url;
|
|
1699
1892
|
if (!wsUrl || typeof wsUrl !== 'string') {
|
|
@@ -1734,17 +1927,17 @@
|
|
|
1734
1927
|
.subscribe(function (t) { return _this.botTranscriptSubject.next(t); }));
|
|
1735
1928
|
// Connect signaling WebSocket (no audio over WS)
|
|
1736
1929
|
this.wsClient.connect(wsUrl);
|
|
1737
|
-
return [3 /*break*/,
|
|
1738
|
-
case
|
|
1930
|
+
return [3 /*break*/, 10];
|
|
1931
|
+
case 8:
|
|
1739
1932
|
error_1 = _a.sent();
|
|
1740
1933
|
console.error('Error connecting voice agent:', error_1);
|
|
1741
1934
|
this.callStateSubject.next('ended');
|
|
1742
1935
|
return [4 /*yield*/, this.disconnect()];
|
|
1743
|
-
case
|
|
1936
|
+
case 9:
|
|
1744
1937
|
_a.sent();
|
|
1745
1938
|
this.statusTextSubject.next('Connection failed');
|
|
1746
1939
|
throw error_1;
|
|
1747
|
-
case
|
|
1940
|
+
case 10: return [2 /*return*/];
|
|
1748
1941
|
}
|
|
1749
1942
|
});
|
|
1750
1943
|
});
|
|
@@ -1844,7 +2037,7 @@
|
|
|
1844
2037
|
};
|
|
1845
2038
|
return VoiceAgentService;
|
|
1846
2039
|
}());
|
|
1847
|
-
VoiceAgentService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function VoiceAgentService_Factory() { return new VoiceAgentService(i0__namespace.ɵɵinject(AudioAnalyzerService), i0__namespace.ɵɵinject(WebSocketVoiceClientService), i0__namespace.ɵɵinject(DailyVoiceClientService)); }, token: VoiceAgentService, providedIn: "root" });
|
|
2040
|
+
VoiceAgentService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function VoiceAgentService_Factory() { return new VoiceAgentService(i0__namespace.ɵɵinject(AudioAnalyzerService), i0__namespace.ɵɵinject(WebSocketVoiceClientService), i0__namespace.ɵɵinject(DailyVoiceClientService), i0__namespace.ɵɵinject(PlatformTokenRefreshService), i0__namespace.ɵɵinject(i0__namespace.PLATFORM_ID)); }, token: VoiceAgentService, providedIn: "root" });
|
|
1848
2041
|
VoiceAgentService.decorators = [
|
|
1849
2042
|
{ type: i0.Injectable, args: [{
|
|
1850
2043
|
providedIn: 'root',
|
|
@@ -1853,7 +2046,9 @@
|
|
|
1853
2046
|
VoiceAgentService.ctorParameters = function () { return [
|
|
1854
2047
|
{ type: AudioAnalyzerService },
|
|
1855
2048
|
{ type: WebSocketVoiceClientService },
|
|
1856
|
-
{ type: DailyVoiceClientService }
|
|
2049
|
+
{ type: DailyVoiceClientService },
|
|
2050
|
+
{ type: PlatformTokenRefreshService },
|
|
2051
|
+
{ type: Object, decorators: [{ type: i0.Inject, args: [i0.PLATFORM_ID,] }] }
|
|
1857
2052
|
]; };
|
|
1858
2053
|
|
|
1859
2054
|
var VOICE_MODAL_CONFIG = new i0.InjectionToken('VOICE_MODAL_CONFIG');
|
|
@@ -1871,6 +2066,7 @@
|
|
|
1871
2066
|
this.domainAuthority = 'prod-lite';
|
|
1872
2067
|
this.agentName = 'AI Assistant';
|
|
1873
2068
|
this.agentRole = 'AI Agent Specialist';
|
|
2069
|
+
this.usersApiUrl = '';
|
|
1874
2070
|
this.injectedConfig = null;
|
|
1875
2071
|
this.onCloseCallback = null;
|
|
1876
2072
|
/** Hardcoded voice agent avatar (Nia). */
|
|
@@ -1889,7 +2085,7 @@
|
|
|
1889
2085
|
}
|
|
1890
2086
|
VoiceAgentModalComponent.prototype.ngOnInit = function () {
|
|
1891
2087
|
var _this = this;
|
|
1892
|
-
var _a, _b, _c, _d, _e, _f;
|
|
2088
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1893
2089
|
// When opened via Overlay, config is provided by injection
|
|
1894
2090
|
this.injectedConfig = this.injector.get(VOICE_MODAL_CONFIG, null);
|
|
1895
2091
|
this.onCloseCallback = this.injector.get(VOICE_MODAL_CLOSE_CALLBACK, null);
|
|
@@ -1905,6 +2101,7 @@
|
|
|
1905
2101
|
this.agentName = (_e = this.injectedConfig.agentName) !== null && _e !== void 0 ? _e : this.agentName;
|
|
1906
2102
|
this.agentRole = (_f = this.injectedConfig.agentRole) !== null && _f !== void 0 ? _f : this.agentRole;
|
|
1907
2103
|
this.agentAvatar = this.injectedConfig.agentAvatar;
|
|
2104
|
+
this.usersApiUrl = (_g = this.injectedConfig.usersApiUrl) !== null && _g !== void 0 ? _g : this.usersApiUrl;
|
|
1908
2105
|
}
|
|
1909
2106
|
// Subscribe to observables
|
|
1910
2107
|
this.subscriptions.push(this.voiceAgentService.callState$.subscribe(function (state) {
|
|
@@ -1943,21 +2140,21 @@
|
|
|
1943
2140
|
VoiceAgentModalComponent.prototype.startCall = function () {
|
|
1944
2141
|
return __awaiter(this, void 0, void 0, function () {
|
|
1945
2142
|
var error_1;
|
|
1946
|
-
return __generator(this, function (
|
|
1947
|
-
switch (
|
|
2143
|
+
return __generator(this, function (_h) {
|
|
2144
|
+
switch (_h.label) {
|
|
1948
2145
|
case 0:
|
|
1949
2146
|
if (this.isConnecting || (this.callState !== 'idle' && this.callState !== 'ended'))
|
|
1950
2147
|
return [2 /*return*/];
|
|
1951
2148
|
this.isConnecting = true;
|
|
1952
|
-
|
|
2149
|
+
_h.label = 1;
|
|
1953
2150
|
case 1:
|
|
1954
|
-
|
|
1955
|
-
return [4 /*yield*/, this.voiceAgentService.connect(this.apiUrl, this.token, this.botId, this.conversationId, this.apiKey, this.eventToken, this.eventUrl, this.domainAuthority)];
|
|
2151
|
+
_h.trys.push([1, 3, 4, 5]);
|
|
2152
|
+
return [4 /*yield*/, this.voiceAgentService.connect(this.apiUrl, this.token, this.botId, this.conversationId, this.apiKey, this.eventToken, this.eventUrl, this.domainAuthority, this.usersApiUrl || undefined)];
|
|
1956
2153
|
case 2:
|
|
1957
|
-
|
|
2154
|
+
_h.sent();
|
|
1958
2155
|
return [3 /*break*/, 5];
|
|
1959
2156
|
case 3:
|
|
1960
|
-
error_1 =
|
|
2157
|
+
error_1 = _h.sent();
|
|
1961
2158
|
console.error('Failed to connect voice agent:', error_1);
|
|
1962
2159
|
return [3 /*break*/, 5];
|
|
1963
2160
|
case 4:
|
|
@@ -1970,11 +2167,11 @@
|
|
|
1970
2167
|
};
|
|
1971
2168
|
VoiceAgentModalComponent.prototype.disconnect = function () {
|
|
1972
2169
|
return __awaiter(this, void 0, void 0, function () {
|
|
1973
|
-
return __generator(this, function (
|
|
1974
|
-
switch (
|
|
2170
|
+
return __generator(this, function (_h) {
|
|
2171
|
+
switch (_h.label) {
|
|
1975
2172
|
case 0: return [4 /*yield*/, this.voiceAgentService.disconnect()];
|
|
1976
2173
|
case 1:
|
|
1977
|
-
|
|
2174
|
+
_h.sent();
|
|
1978
2175
|
return [2 /*return*/];
|
|
1979
2176
|
}
|
|
1980
2177
|
});
|
|
@@ -2050,7 +2247,8 @@
|
|
|
2050
2247
|
domainAuthority: [{ type: i0.Input }],
|
|
2051
2248
|
agentName: [{ type: i0.Input }],
|
|
2052
2249
|
agentRole: [{ type: i0.Input }],
|
|
2053
|
-
agentAvatar: [{ type: i0.Input }]
|
|
2250
|
+
agentAvatar: [{ type: i0.Input }],
|
|
2251
|
+
usersApiUrl: [{ type: i0.Input }]
|
|
2054
2252
|
};
|
|
2055
2253
|
|
|
2056
2254
|
exports.eClassificationType = void 0;
|
|
@@ -2061,7 +2259,7 @@
|
|
|
2061
2259
|
})(exports.eClassificationType || (exports.eClassificationType = {}));
|
|
2062
2260
|
var ChatDrawerComponent = /** @class */ (function () {
|
|
2063
2261
|
function ChatDrawerComponent(fb, botService, cdr, http, sanitizer, elementRef, renderer, socketService, conversationService, // private platform: Platform
|
|
2064
|
-
translationService, voiceAgentService, overlay, viewContainerRef, injector) {
|
|
2262
|
+
translationService, voiceAgentService, overlay, viewContainerRef, injector, platformTokenRefresh) {
|
|
2065
2263
|
var _this = this;
|
|
2066
2264
|
this.fb = fb;
|
|
2067
2265
|
this.botService = botService;
|
|
@@ -2077,6 +2275,7 @@
|
|
|
2077
2275
|
this.overlay = overlay;
|
|
2078
2276
|
this.viewContainerRef = viewContainerRef;
|
|
2079
2277
|
this.injector = injector;
|
|
2278
|
+
this.platformTokenRefresh = platformTokenRefresh;
|
|
2080
2279
|
this.bodyOverflowClass = 'body-overflow-hidden';
|
|
2081
2280
|
this.isCollapsedTrue = false;
|
|
2082
2281
|
this.copilotName = 'HiveXGPT';
|
|
@@ -2105,6 +2304,8 @@
|
|
|
2105
2304
|
this.viewBooth = new i0.EventEmitter();
|
|
2106
2305
|
this.scheduleMeeting = new i0.EventEmitter();
|
|
2107
2306
|
this.refreshToken = new i0.EventEmitter();
|
|
2307
|
+
/** Emitted after a successful `user/tokenRefresh` so the host can dispatch Login / `saveTokenAndLoginUser`. */
|
|
2308
|
+
this.tokensRefreshed = new i0.EventEmitter();
|
|
2108
2309
|
this.openSupport = new i0.EventEmitter();
|
|
2109
2310
|
this.autogenKey = 'Autogen_eDJTtEU-NB0RtIpzq1w';
|
|
2110
2311
|
this.addToMyAgendaAction = 'add_to_my_agenda';
|
|
@@ -5272,9 +5473,45 @@
|
|
|
5272
5473
|
body['workflow_id'] = workflowId;
|
|
5273
5474
|
body['workflow_inputs'] = workflow_inputs;
|
|
5274
5475
|
}
|
|
5476
|
+
var usersApi = this.environment.USERS_API;
|
|
5477
|
+
this.platformTokenRefresh
|
|
5478
|
+
.ensureValidAccessToken(this.s27Token, usersApi)
|
|
5479
|
+
.pipe(operators.take(1))
|
|
5480
|
+
.subscribe({
|
|
5481
|
+
next: function (ensured) {
|
|
5482
|
+
var bearer = ensured.accessToken || _this.s27Token || '';
|
|
5483
|
+
if (ensured.refreshed && ensured.accessToken) {
|
|
5484
|
+
_this.s27Token = ensured.accessToken;
|
|
5485
|
+
if (ensured.authResponse) {
|
|
5486
|
+
_this.tokensRefreshed.emit(ensured.authResponse);
|
|
5487
|
+
}
|
|
5488
|
+
}
|
|
5489
|
+
_this.executeAskFetch(url, body, bearer, msg, chat);
|
|
5490
|
+
},
|
|
5491
|
+
error: function () {
|
|
5492
|
+
_this.is401 = true;
|
|
5493
|
+
_this.refreshToken.emit();
|
|
5494
|
+
if (msg && chat) {
|
|
5495
|
+
_this.msg = msg;
|
|
5496
|
+
_this.chat = chat;
|
|
5497
|
+
_this.isFetchDataFor = true;
|
|
5498
|
+
}
|
|
5499
|
+
_this.isChatingWithAi = false;
|
|
5500
|
+
},
|
|
5501
|
+
});
|
|
5502
|
+
this.input = '';
|
|
5503
|
+
this.selectedWorkflow = null;
|
|
5504
|
+
this.openWorkflowInput = false;
|
|
5505
|
+
this.isWorkflowOpen = false;
|
|
5506
|
+
this.scrollToBottom();
|
|
5507
|
+
this.cdr.markForCheck();
|
|
5508
|
+
};
|
|
5509
|
+
/** `/ai/ask` fetch using a Bearer token (after optional proactive refresh). */
|
|
5510
|
+
ChatDrawerComponent.prototype.executeAskFetch = function (url, body, bearerToken, msg, chat) {
|
|
5511
|
+
var _this = this;
|
|
5275
5512
|
var headers = {
|
|
5276
5513
|
'Content-Type': 'application/json',
|
|
5277
|
-
Authorization: 'Bearer ' +
|
|
5514
|
+
Authorization: 'Bearer ' + bearerToken,
|
|
5278
5515
|
'x-api-key': this.apiKey,
|
|
5279
5516
|
'hive-bot-id': this.botId,
|
|
5280
5517
|
'domain-authority': this.domainAuthorityValue,
|
|
@@ -5294,7 +5531,6 @@
|
|
|
5294
5531
|
if (response.status === 401 || response.status === 403) {
|
|
5295
5532
|
_this.is401 = true;
|
|
5296
5533
|
_this.refreshToken.emit();
|
|
5297
|
-
// If `msg` and `chat` exist, handle them
|
|
5298
5534
|
if (msg && chat) {
|
|
5299
5535
|
_this.msg = msg;
|
|
5300
5536
|
_this.chat = chat;
|
|
@@ -5308,18 +5544,11 @@
|
|
|
5308
5544
|
})
|
|
5309
5545
|
.then(function (data) {
|
|
5310
5546
|
console.log(data);
|
|
5311
|
-
// Additional response handling if needed
|
|
5312
5547
|
})
|
|
5313
5548
|
.catch(function (err) {
|
|
5314
5549
|
console.error('Error: ', err);
|
|
5315
5550
|
_this.isChatingWithAi = false;
|
|
5316
5551
|
});
|
|
5317
|
-
this.input = '';
|
|
5318
|
-
this.selectedWorkflow = null;
|
|
5319
|
-
this.openWorkflowInput = false;
|
|
5320
|
-
this.isWorkflowOpen = false;
|
|
5321
|
-
this.scrollToBottom();
|
|
5322
|
-
this.cdr.markForCheck();
|
|
5323
5552
|
};
|
|
5324
5553
|
ChatDrawerComponent.prototype.makeAskRequestold = function (inputMsg, agents, conversationId, msg, chat, workflowId, workflow_inputs) {
|
|
5325
5554
|
var _this = this;
|
|
@@ -5489,7 +5718,7 @@
|
|
|
5489
5718
|
};
|
|
5490
5719
|
ChatDrawerComponent.prototype.openVoiceModal = function () {
|
|
5491
5720
|
var _this = this;
|
|
5492
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
5721
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
5493
5722
|
var conversationId = (_b = (_a = this.conversationKey) !== null && _a !== void 0 ? _a : this.conversationService.getKey(this.botId, false, this.eventId)) !== null && _b !== void 0 ? _b : '';
|
|
5494
5723
|
this.voiceModalConversationId = conversationId;
|
|
5495
5724
|
this.setupVoiceTranscripts();
|
|
@@ -5511,6 +5740,7 @@
|
|
|
5511
5740
|
agentName: this.botName || 'AI Assistant',
|
|
5512
5741
|
agentRole: this.botSkills || 'AI Agent Specialist',
|
|
5513
5742
|
agentAvatar: this.botIcon,
|
|
5743
|
+
usersApiUrl: (_m = (_l = this.environment) === null || _l === void 0 ? void 0 : _l.USERS_API) !== null && _m !== void 0 ? _m : '',
|
|
5514
5744
|
};
|
|
5515
5745
|
var closeCallback = function () {
|
|
5516
5746
|
if (_this.voiceModalOverlayRef) {
|
|
@@ -5850,7 +6080,8 @@
|
|
|
5850
6080
|
{ type: VoiceAgentService },
|
|
5851
6081
|
{ type: overlay.Overlay },
|
|
5852
6082
|
{ type: i0.ViewContainerRef },
|
|
5853
|
-
{ type: i0.Injector }
|
|
6083
|
+
{ type: i0.Injector },
|
|
6084
|
+
{ type: PlatformTokenRefreshService }
|
|
5854
6085
|
]; };
|
|
5855
6086
|
ChatDrawerComponent.propDecorators = {
|
|
5856
6087
|
chatMain: [{ type: i0.ViewChild, args: ['chatMain',] }],
|
|
@@ -5920,11 +6151,13 @@
|
|
|
5920
6151
|
viewBooth: [{ type: i0.Output }],
|
|
5921
6152
|
scheduleMeeting: [{ type: i0.Output }],
|
|
5922
6153
|
refreshToken: [{ type: i0.Output }],
|
|
6154
|
+
tokensRefreshed: [{ type: i0.Output }],
|
|
5923
6155
|
openSupport: [{ type: i0.Output }]
|
|
5924
6156
|
};
|
|
5925
6157
|
|
|
5926
6158
|
var ChatBotComponent = /** @class */ (function () {
|
|
5927
6159
|
function ChatBotComponent() {
|
|
6160
|
+
this.tokensRefreshed = new i0.EventEmitter();
|
|
5928
6161
|
this.visible = false;
|
|
5929
6162
|
}
|
|
5930
6163
|
ChatBotComponent.prototype.toggle = function () {
|
|
@@ -5935,7 +6168,7 @@
|
|
|
5935
6168
|
ChatBotComponent.decorators = [
|
|
5936
6169
|
{ type: i0.Component, args: [{
|
|
5937
6170
|
selector: 'hivegpt-chatbot',
|
|
5938
|
-
template: "<button mat-icon-button class=\"chat-button\" color=\"primary\" (click)=\"toggle()\">\n <mat-icon>chat</mat-icon>\n</button>\n\n<ng-container *ngIf=\"visible\">\n <hivegpt-chat-drawer-package\n [apiKey]=\"apiKey\"\n [bgBubbleAi]=\"bgBubbleAi\"\n [bgBubbleUser]=\"bgBubbleUser\"\n [bgGradient]=\"bgGradient\"\n [botName]=\"botName\"\n [closeButtonbgColor]=\"closeButtonbgColor\"\n [closeButtonColor]=\"closeButtonColor\"\n [credentials]=\"credentials\"\n [dateTextColor]=\"dateTextColor\"\n [dateTimeColor]=\"dateTimeColor\"\n [eventId]=\"eventId\"\n [eventName]=\"eventName\"\n [formFieldBgColor]=\"formFieldBgColor\"\n [formFieldTextColor]=\"formFieldTextColor\"\n [fullView]=\"fullView\"\n [greeting]=\"greeting\"\n [gradientColors]=\"gradientColors\"\n [messageTextColorAi]=\"messageTextColorAi\"\n [messageTextColorUser]=\"messageTextColorUser\"\n [sendButtonColor]=\"sendButtonColor\"\n [sendButtonTextColor]=\"sendButtonTextColor\"\n [showClose]=\"showClose\"\n [thumbsDownMessages]=\"thumbsDownMessages\"\n [thumbsUpMessage]=\"thumbsUpMessage\"\n [unknownResponses]=\"unknownResponses\"\n [useOpenAi]=\"useOpenAi\"\n [userId]=\"userId\"\n [userAvatarUrl]=\"userAvatarUrl\"\n [timezone]=\"timezone\"\n [botId]=\"botId\"\n [s27Token]=\"s27Token\"\n [workspaceToken]=\"workspaceToken\"\n [isDev]=\"isDev\"\n [baseUrl]=\"baseUrl\"\n >\n </hivegpt-chat-drawer-package>\n</ng-container>\n",
|
|
6171
|
+
template: "<button mat-icon-button class=\"chat-button\" color=\"primary\" (click)=\"toggle()\">\n <mat-icon>chat</mat-icon>\n</button>\n\n<ng-container *ngIf=\"visible\">\n <hivegpt-chat-drawer-package\n [apiKey]=\"apiKey\"\n [bgBubbleAi]=\"bgBubbleAi\"\n [bgBubbleUser]=\"bgBubbleUser\"\n [bgGradient]=\"bgGradient\"\n [botName]=\"botName\"\n [closeButtonbgColor]=\"closeButtonbgColor\"\n [closeButtonColor]=\"closeButtonColor\"\n [credentials]=\"credentials\"\n [dateTextColor]=\"dateTextColor\"\n [dateTimeColor]=\"dateTimeColor\"\n [eventId]=\"eventId\"\n [eventName]=\"eventName\"\n [formFieldBgColor]=\"formFieldBgColor\"\n [formFieldTextColor]=\"formFieldTextColor\"\n [fullView]=\"fullView\"\n [greeting]=\"greeting\"\n [gradientColors]=\"gradientColors\"\n [messageTextColorAi]=\"messageTextColorAi\"\n [messageTextColorUser]=\"messageTextColorUser\"\n [sendButtonColor]=\"sendButtonColor\"\n [sendButtonTextColor]=\"sendButtonTextColor\"\n [showClose]=\"showClose\"\n [thumbsDownMessages]=\"thumbsDownMessages\"\n [thumbsUpMessage]=\"thumbsUpMessage\"\n [unknownResponses]=\"unknownResponses\"\n [useOpenAi]=\"useOpenAi\"\n [userId]=\"userId\"\n [userAvatarUrl]=\"userAvatarUrl\"\n [timezone]=\"timezone\"\n [botId]=\"botId\"\n [s27Token]=\"s27Token\"\n (tokensRefreshed)=\"tokensRefreshed.emit($event)\"\n [workspaceToken]=\"workspaceToken\"\n [isDev]=\"isDev\"\n [baseUrl]=\"baseUrl\"\n >\n </hivegpt-chat-drawer-package>\n</ng-container>\n",
|
|
5939
6172
|
styles: ["::-webkit-scrollbar{width:5px}::-webkit-scrollbar-track{background:#f1f1f1}::-webkit-scrollbar-thumb,::-webkit-scrollbar-thumb:hover{background:#e5ccbc}.spinner{align-items:center;display:flex;gap:2px;justify-content:center}.spinner>div{animation:bouncedelay 1.4s ease-in-out infinite;animation-fill-mode:both;background-color:#173330;border-radius:100%;display:inline-block;height:5px;width:5px}.spinner .bounce1{animation-delay:-.32s}.spinner .bounce2{animation-delay:-.16s}@keyframes bouncedelay{0%,80%,to{-webkit-transform:scale(0);transform:scale(0)}40%{-webkit-transform:scale(1);transform:scale(1)}}.chat-button{align-items:center;background:#17235b;border:#17235b;border-radius:50%;bottom:20px;color:#fff;display:inline-flex;font-size:24px;height:50px;justify-content:center;position:fixed;right:20px;width:50px}"]
|
|
5940
6173
|
},] }
|
|
5941
6174
|
];
|
|
@@ -5973,6 +6206,7 @@
|
|
|
5973
6206
|
rules: [{ type: i0.Input }],
|
|
5974
6207
|
eventId: [{ type: i0.Input }],
|
|
5975
6208
|
s27Token: [{ type: i0.Input }],
|
|
6209
|
+
tokensRefreshed: [{ type: i0.Output }],
|
|
5976
6210
|
workspaceToken: [{ type: i0.Input }],
|
|
5977
6211
|
isDev: [{ type: i0.Input }],
|
|
5978
6212
|
baseUrl: [{ type: i0.Input }]
|
|
@@ -6286,12 +6520,15 @@
|
|
|
6286
6520
|
exports.AudioAnalyzerService = AudioAnalyzerService;
|
|
6287
6521
|
exports.ChatBotComponent = ChatBotComponent;
|
|
6288
6522
|
exports.ChatDrawerComponent = ChatDrawerComponent;
|
|
6523
|
+
exports.HIVEGPT_AUTH_STORAGE_KEY = HIVEGPT_AUTH_STORAGE_KEY;
|
|
6289
6524
|
exports.HiveGptModule = HiveGptModule;
|
|
6525
|
+
exports.PlatformTokenRefreshService = PlatformTokenRefreshService;
|
|
6290
6526
|
exports.VOICE_MODAL_CLOSE_CALLBACK = VOICE_MODAL_CLOSE_CALLBACK;
|
|
6291
6527
|
exports.VOICE_MODAL_CONFIG = VOICE_MODAL_CONFIG;
|
|
6292
6528
|
exports.VoiceAgentModalComponent = VoiceAgentModalComponent;
|
|
6293
6529
|
exports.VoiceAgentModule = VoiceAgentModule;
|
|
6294
6530
|
exports.VoiceAgentService = VoiceAgentService;
|
|
6531
|
+
exports.hiveGptAuthStorageKeyFactory = hiveGptAuthStorageKeyFactory;
|
|
6295
6532
|
exports["ɵa"] = BotsService;
|
|
6296
6533
|
exports["ɵb"] = SocketService;
|
|
6297
6534
|
exports["ɵc"] = ConversationService;
|