@hivegpt/hiveai-angular 0.0.479 → 0.0.480
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 +29 -78
- 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/chat-drawer/chat-drawer.component.js +3 -1
- package/esm2015/lib/components/voice-agent/components/voice-agent-modal/voice-agent-modal.component.js +9 -5
- package/esm2015/lib/components/voice-agent/services/voice-agent.service.js +19 -68
- package/fesm2015/hivegpt-hiveai-angular.js +28 -71
- package/fesm2015/hivegpt-hiveai-angular.js.map +1 -1
- package/hivegpt-hiveai-angular.metadata.json +1 -1
- package/lib/components/chat-drawer/chat-drawer.component.d.ts.map +1 -1
- 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 -9
- package/lib/components/voice-agent/services/voice-agent.service.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1587,15 +1587,11 @@
|
|
|
1587
1587
|
/** Static Daily.co room URL (used instead of dynamic room_created from backend). */
|
|
1588
1588
|
var STATIC_DAILY_ROOM_URL = 'https://cloud-4a46e9dfbc8c499daddd480d9c294b88.daily.co/voice-None-1772776583';
|
|
1589
1589
|
/**
|
|
1590
|
-
* Voice agent orchestrator.
|
|
1590
|
+
* Voice agent orchestrator. Connects directly to a hardcoded Daily.co room — no API or WebSocket.
|
|
1591
1591
|
*
|
|
1592
|
-
*
|
|
1593
|
-
* -
|
|
1594
|
-
* -
|
|
1595
|
-
*
|
|
1596
|
-
* - Maintains callState, statusText, duration, isMicMuted, isUserSpeaking, audioLevels
|
|
1597
|
-
* - Uses WebSocket for transcripts only (no audio)
|
|
1598
|
-
* - Uses Daily.js for all audio, mic, and real-time speaking detection
|
|
1592
|
+
* - When the modal opens, connect() is called and joins STATIC_DAILY_ROOM_URL immediately.
|
|
1593
|
+
* - Daily.js (DailyVoiceClientService) handles all WebRTC audio, mic, and speaking detection.
|
|
1594
|
+
* - Maintains callState, statusText, duration, isMicMuted, isUserSpeaking, audioLevels.
|
|
1599
1595
|
*/
|
|
1600
1596
|
var VoiceAgentService = /** @class */ (function () {
|
|
1601
1597
|
function VoiceAgentService(audioAnalyzer, wsClient, dailyClient) {
|
|
@@ -1626,6 +1622,10 @@
|
|
|
1626
1622
|
// Waveform visualization only - do NOT use for speaking state
|
|
1627
1623
|
this.subscriptions.add(this.audioAnalyzer.audioLevels$.subscribe(function (levels) { return _this.audioLevelsSubject.next(levels); }));
|
|
1628
1624
|
}
|
|
1625
|
+
/** Current call state (for checking if connection was already started). */
|
|
1626
|
+
VoiceAgentService.prototype.getCallState = function () {
|
|
1627
|
+
return this.callStateSubject.value;
|
|
1628
|
+
};
|
|
1629
1629
|
VoiceAgentService.prototype.ngOnDestroy = function () {
|
|
1630
1630
|
this.destroy$.next();
|
|
1631
1631
|
this.subscriptions.unsubscribe();
|
|
@@ -1644,10 +1644,10 @@
|
|
|
1644
1644
|
this.statusTextSubject.next('');
|
|
1645
1645
|
this.durationSubject.next('0:00');
|
|
1646
1646
|
};
|
|
1647
|
-
|
|
1647
|
+
/** Connect directly to the hardcoded Daily room. No API or WebSocket — as soon as modal opens. */
|
|
1648
|
+
VoiceAgentService.prototype.connect = function () {
|
|
1648
1649
|
return __awaiter(this, void 0, void 0, function () {
|
|
1649
|
-
var
|
|
1650
|
-
var _this = this;
|
|
1650
|
+
var err_1;
|
|
1651
1651
|
return __generator(this, function (_a) {
|
|
1652
1652
|
switch (_a.label) {
|
|
1653
1653
|
case 0:
|
|
@@ -1655,80 +1655,25 @@
|
|
|
1655
1655
|
console.warn('Call already in progress');
|
|
1656
1656
|
return [2 /*return*/];
|
|
1657
1657
|
}
|
|
1658
|
-
_a.label = 1;
|
|
1659
|
-
case 1:
|
|
1660
|
-
_a.trys.push([1, 9, , 11]);
|
|
1661
1658
|
this.callStateSubject.next('connecting');
|
|
1662
1659
|
this.statusTextSubject.next('Connecting...');
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
'Content-Type': 'application/json',
|
|
1667
|
-
Authorization: "Bearer " + token,
|
|
1668
|
-
'domain-authority': domainAuthority,
|
|
1669
|
-
'eventtoken': eventToken,
|
|
1670
|
-
'eventurl': eventUrl,
|
|
1671
|
-
'hive-bot-id': botId,
|
|
1672
|
-
'x-api-key': apiKey,
|
|
1673
|
-
"ngrok-skip-browser-warning": "true"
|
|
1674
|
-
};
|
|
1675
|
-
return [4 /*yield*/, fetch(postUrl, {
|
|
1676
|
-
method: 'POST',
|
|
1677
|
-
headers: headers,
|
|
1678
|
-
body: JSON.stringify({
|
|
1679
|
-
bot_id: botId,
|
|
1680
|
-
conversation_id: conversationId,
|
|
1681
|
-
voice: 'alloy',
|
|
1682
|
-
}),
|
|
1683
|
-
})];
|
|
1684
|
-
case 2:
|
|
1685
|
-
res = _a.sent();
|
|
1686
|
-
if (!res.ok) {
|
|
1687
|
-
throw new Error("HTTP " + res.status);
|
|
1688
|
-
}
|
|
1689
|
-
return [4 /*yield*/, res.json()];
|
|
1690
|
-
case 3:
|
|
1691
|
-
json = _a.sent();
|
|
1692
|
-
wsUrl = json === null || json === void 0 ? void 0 : json.rn_ws_url;
|
|
1693
|
-
if (!wsUrl || typeof wsUrl !== 'string') {
|
|
1694
|
-
throw new Error('No ws_url in response');
|
|
1695
|
-
}
|
|
1696
|
-
// Forward transcripts from WebSocket
|
|
1697
|
-
this.subscriptions.add(this.wsClient.userTranscript$
|
|
1698
|
-
.pipe(operators.takeUntil(this.destroy$))
|
|
1699
|
-
.subscribe(function (t) { return _this.userTranscriptSubject.next(t); }));
|
|
1700
|
-
this.subscriptions.add(this.wsClient.botTranscript$
|
|
1701
|
-
.pipe(operators.takeUntil(this.destroy$))
|
|
1702
|
-
.subscribe(function (t) { return _this.botTranscriptSubject.next(t); }));
|
|
1703
|
-
// Connect signaling WebSocket (no audio over WS)
|
|
1704
|
-
this.wsClient.connect(wsUrl);
|
|
1705
|
-
_a.label = 4;
|
|
1706
|
-
case 4:
|
|
1707
|
-
_a.trys.push([4, 6, , 8]);
|
|
1660
|
+
_a.label = 1;
|
|
1661
|
+
case 1:
|
|
1662
|
+
_a.trys.push([1, 3, , 5]);
|
|
1708
1663
|
return [4 /*yield*/, this.onRoomCreated(STATIC_DAILY_ROOM_URL)];
|
|
1709
|
-
case
|
|
1664
|
+
case 2:
|
|
1710
1665
|
_a.sent();
|
|
1711
|
-
return [3 /*break*/,
|
|
1712
|
-
case
|
|
1666
|
+
return [3 /*break*/, 5];
|
|
1667
|
+
case 3:
|
|
1713
1668
|
err_1 = _a.sent();
|
|
1714
1669
|
console.error('Daily join failed:', err_1);
|
|
1715
1670
|
this.callStateSubject.next('ended');
|
|
1716
1671
|
this.statusTextSubject.next('Connection failed');
|
|
1717
1672
|
return [4 /*yield*/, this.disconnect()];
|
|
1718
|
-
case
|
|
1673
|
+
case 4:
|
|
1719
1674
|
_a.sent();
|
|
1720
1675
|
throw err_1;
|
|
1721
|
-
case
|
|
1722
|
-
case 9:
|
|
1723
|
-
error_1 = _a.sent();
|
|
1724
|
-
console.error('Error connecting voice agent:', error_1);
|
|
1725
|
-
this.callStateSubject.next('ended');
|
|
1726
|
-
return [4 /*yield*/, this.disconnect()];
|
|
1727
|
-
case 10:
|
|
1728
|
-
_a.sent();
|
|
1729
|
-
this.statusTextSubject.next('Connection failed');
|
|
1730
|
-
throw error_1;
|
|
1731
|
-
case 11: return [2 /*return*/];
|
|
1676
|
+
case 5: return [2 /*return*/];
|
|
1732
1677
|
}
|
|
1733
1678
|
});
|
|
1734
1679
|
});
|
|
@@ -1918,9 +1863,13 @@
|
|
|
1918
1863
|
this.subscriptions.push(this.voiceAgentService.audioLevels$.subscribe(function (levels) {
|
|
1919
1864
|
_this.audioLevels = levels;
|
|
1920
1865
|
}));
|
|
1921
|
-
//
|
|
1922
|
-
this.voiceAgentService.
|
|
1923
|
-
|
|
1866
|
+
// If connection was already started from the drawer (openVoiceModal), don't reset or start again.
|
|
1867
|
+
var state = this.voiceAgentService.getCallState();
|
|
1868
|
+
var alreadyStarted = state !== 'idle' && state !== 'ended';
|
|
1869
|
+
if (!alreadyStarted) {
|
|
1870
|
+
this.voiceAgentService.resetToIdle();
|
|
1871
|
+
void this.startCall();
|
|
1872
|
+
}
|
|
1924
1873
|
};
|
|
1925
1874
|
VoiceAgentModalComponent.prototype.ngOnDestroy = function () {
|
|
1926
1875
|
this.subscriptions.forEach(function (sub) { return sub.unsubscribe(); });
|
|
@@ -1938,7 +1887,7 @@
|
|
|
1938
1887
|
_g.label = 1;
|
|
1939
1888
|
case 1:
|
|
1940
1889
|
_g.trys.push([1, 3, 4, 5]);
|
|
1941
|
-
return [4 /*yield*/, this.voiceAgentService.connect(
|
|
1890
|
+
return [4 /*yield*/, this.voiceAgentService.connect()];
|
|
1942
1891
|
case 2:
|
|
1943
1892
|
_g.sent();
|
|
1944
1893
|
return [3 /*break*/, 5];
|
|
@@ -4295,6 +4244,8 @@
|
|
|
4295
4244
|
var conversationId = (_b = (_a = this.conversationKey) !== null && _a !== void 0 ? _a : this.conversationService.getKey(this.botId, false)) !== null && _b !== void 0 ? _b : '';
|
|
4296
4245
|
this.voiceModalConversationId = conversationId;
|
|
4297
4246
|
this.setupVoiceTranscripts();
|
|
4247
|
+
// Start connecting to the voice room immediately (no wait for modal to open)
|
|
4248
|
+
void this.voiceAgentService.connect();
|
|
4298
4249
|
// Close existing overlay if any
|
|
4299
4250
|
if (this.voiceModalOverlayRef) {
|
|
4300
4251
|
this.voiceModalOverlayRef.detach();
|