@hivegpt/hiveai-angular 0.0.428 → 0.0.430

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.
@@ -1291,7 +1291,7 @@
1291
1291
  */
1292
1292
  DailyVoiceClientService.prototype.connect = function (roomUrl, token) {
1293
1293
  return __awaiter(this, void 0, void 0, function () {
1294
- var stream, audioTrack, callObject, participants, err_1;
1294
+ var stream, audioTrack, callObject, joinOptions, participants, err_1;
1295
1295
  return __generator(this, function (_c) {
1296
1296
  switch (_c.label) {
1297
1297
  case 0:
@@ -1318,10 +1318,12 @@
1318
1318
  });
1319
1319
  this.callObject = callObject;
1320
1320
  this.setupEventHandlers(callObject);
1321
- // Join room; Daily handles playback of remote (bot) audio automatically
1322
- return [4 /*yield*/, callObject.join({ url: roomUrl, token: token })];
1321
+ joinOptions = { url: roomUrl };
1322
+ if (typeof token === 'string' && token.trim() !== '') {
1323
+ joinOptions.token = token;
1324
+ }
1325
+ return [4 /*yield*/, callObject.join(joinOptions)];
1323
1326
  case 4:
1324
- // Join room; Daily handles playback of remote (bot) audio automatically
1325
1327
  _c.sent();
1326
1328
  participants = callObject.participants();
1327
1329
  if (participants === null || participants === void 0 ? void 0 : participants.local) {
@@ -1512,24 +1514,23 @@
1512
1514
  this.durationSubject.next('0:00');
1513
1515
  };
1514
1516
  VoiceAgentService.prototype.connect = function (apiUrl, token, botId, conversationId, apiKey, eventToken, eventUrl, domainAuthority) {
1515
- var _a;
1516
1517
  return __awaiter(this, void 0, void 0, function () {
1517
1518
  var baseUrl, postUrl, headers, res, json, wsUrl, error_1;
1518
1519
  var _this = this;
1519
- return __generator(this, function (_b) {
1520
- switch (_b.label) {
1520
+ return __generator(this, function (_a) {
1521
+ switch (_a.label) {
1521
1522
  case 0:
1522
1523
  if (this.callStateSubject.value !== 'idle') {
1523
1524
  console.warn('Call already in progress');
1524
1525
  return [2 /*return*/];
1525
1526
  }
1526
- _b.label = 1;
1527
+ _a.label = 1;
1527
1528
  case 1:
1528
- _b.trys.push([1, 4, , 6]);
1529
+ _a.trys.push([1, 4, , 6]);
1529
1530
  this.callStateSubject.next('connecting');
1530
1531
  this.statusTextSubject.next('Connecting...');
1531
1532
  baseUrl = apiUrl.replace(/\/$/, '');
1532
- postUrl = baseUrl + "/ai/ask-voice";
1533
+ postUrl = "https://48c6-2405-201-5c02-991e-d91c-8adf-399c-abdc.ngrok-free.app/ai/ask-voice";
1533
1534
  headers = {
1534
1535
  'Content-Type': 'application/json',
1535
1536
  Authorization: "Bearer " + token,
@@ -1549,14 +1550,14 @@
1549
1550
  }),
1550
1551
  })];
1551
1552
  case 2:
1552
- res = _b.sent();
1553
+ res = _a.sent();
1553
1554
  if (!res.ok) {
1554
1555
  throw new Error("HTTP " + res.status);
1555
1556
  }
1556
1557
  return [4 /*yield*/, res.json()];
1557
1558
  case 3:
1558
- json = _b.sent();
1559
- wsUrl = (_a = json === null || json === void 0 ? void 0 : json.ws_url) !== null && _a !== void 0 ? _a : json === null || json === void 0 ? void 0 : json.rn_ws_url;
1559
+ json = _a.sent();
1560
+ wsUrl = json === null || json === void 0 ? void 0 : json.rn_ws_url;
1560
1561
  if (!wsUrl || typeof wsUrl !== 'string') {
1561
1562
  throw new Error('No ws_url in response');
1562
1563
  }
@@ -1565,22 +1566,22 @@
1565
1566
  .pipe(operators.take(1), operators.takeUntil(this.destroy$))
1566
1567
  .subscribe(function (roomUrl) { return __awaiter(_this, void 0, void 0, function () {
1567
1568
  var err_1;
1568
- return __generator(this, function (_b) {
1569
- switch (_b.label) {
1569
+ return __generator(this, function (_a) {
1570
+ switch (_a.label) {
1570
1571
  case 0:
1571
- _b.trys.push([0, 2, , 4]);
1572
+ _a.trys.push([0, 2, , 4]);
1572
1573
  return [4 /*yield*/, this.onRoomCreated(roomUrl)];
1573
1574
  case 1:
1574
- _b.sent();
1575
+ _a.sent();
1575
1576
  return [3 /*break*/, 4];
1576
1577
  case 2:
1577
- err_1 = _b.sent();
1578
+ err_1 = _a.sent();
1578
1579
  console.error('Daily join failed:', err_1);
1579
1580
  this.callStateSubject.next('ended');
1580
1581
  this.statusTextSubject.next('Connection failed');
1581
1582
  return [4 /*yield*/, this.disconnect()];
1582
1583
  case 3:
1583
- _b.sent();
1584
+ _a.sent();
1584
1585
  throw err_1;
1585
1586
  case 4: return [2 /*return*/];
1586
1587
  }
@@ -1597,12 +1598,12 @@
1597
1598
  this.wsClient.connect(wsUrl);
1598
1599
  return [3 /*break*/, 6];
1599
1600
  case 4:
1600
- error_1 = _b.sent();
1601
+ error_1 = _a.sent();
1601
1602
  console.error('Error connecting voice agent:', error_1);
1602
1603
  this.callStateSubject.next('ended');
1603
1604
  return [4 /*yield*/, this.disconnect()];
1604
1605
  case 5:
1605
- _b.sent();
1606
+ _a.sent();
1606
1607
  this.statusTextSubject.next('Connection failed');
1607
1608
  throw error_1;
1608
1609
  case 6: return [2 /*return*/];
@@ -1613,14 +1614,14 @@
1613
1614
  VoiceAgentService.prototype.onRoomCreated = function (roomUrl) {
1614
1615
  return __awaiter(this, void 0, void 0, function () {
1615
1616
  var _this = this;
1616
- return __generator(this, function (_b) {
1617
- switch (_b.label) {
1617
+ return __generator(this, function (_a) {
1618
+ switch (_a.label) {
1618
1619
  case 0:
1619
1620
  // Connect Daily.js for WebRTC audio
1620
1621
  return [4 /*yield*/, this.dailyClient.connect(roomUrl)];
1621
1622
  case 1:
1622
1623
  // Connect Daily.js for WebRTC audio
1623
- _b.sent();
1624
+ _a.sent();
1624
1625
  // Waveform: use local mic stream from Daily client
1625
1626
  this.dailyClient.localStream$
1626
1627
  .pipe(operators.filter(function (s) { return s != null; }), operators.take(1))
@@ -1633,8 +1634,8 @@
1633
1634
  this.subscriptions.add(rxjs.combineLatest([
1634
1635
  this.dailyClient.speaking$,
1635
1636
  this.dailyClient.userSpeaking$,
1636
- ]).subscribe(function (_b) {
1637
- var _c = __read(_b, 2), bot = _c[0], user = _c[1];
1637
+ ]).subscribe(function (_a) {
1638
+ var _b = __read(_a, 2), bot = _b[0], user = _b[1];
1638
1639
  if (user) {
1639
1640
  _this.callStateSubject.next('listening');
1640
1641
  }
@@ -1658,8 +1659,8 @@
1658
1659
  };
1659
1660
  VoiceAgentService.prototype.disconnect = function () {
1660
1661
  return __awaiter(this, void 0, void 0, function () {
1661
- return __generator(this, function (_b) {
1662
- switch (_b.label) {
1662
+ return __generator(this, function (_a) {
1663
+ switch (_a.label) {
1663
1664
  case 0:
1664
1665
  this.stopDurationTimer();
1665
1666
  this.audioAnalyzer.stop();
@@ -1667,7 +1668,7 @@
1667
1668
  return [4 /*yield*/, this.dailyClient.disconnect()];
1668
1669
  case 1:
1669
1670
  // Daily first, then WebSocket
1670
- _b.sent();
1671
+ _a.sent();
1671
1672
  this.wsClient.disconnect();
1672
1673
  this.callStateSubject.next('ended');
1673
1674
  this.statusTextSubject.next('Call Ended');