@hivegpt/hiveai-angular 0.0.575 → 0.0.576

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.
@@ -1438,7 +1438,9 @@
1438
1438
  reject(new Error('WebSocket connection failed'));
1439
1439
  return;
1440
1440
  }
1441
- _this.disconnect();
1441
+ // After onopen, some environments fire onerror spuriously; closing here can
1442
+ // kill the socket before room_created is delivered. Let onclose clean up.
1443
+ console.warn('WebSocketVoiceClient: onerror after open (not forcing disconnect)');
1442
1444
  };
1443
1445
  ws.onclose = function () {
1444
1446
  _this.ws = null;
@@ -1897,7 +1899,7 @@
1897
1899
  VoiceAgentService.prototype.connect = function (apiUrl, token, botId, conversationId, apiKey, eventToken, eventId, eventUrl, domainAuthority, usersApiUrl, existingMicStream) {
1898
1900
  var _a;
1899
1901
  return __awaiter(this, void 0, void 0, function () {
1900
- var tokenPromise, prepPromise, micPromise, _b, accessToken, _c, postUrl, body, micStream_1, headers, res, json, wsUrl, error_1;
1902
+ var tokenPromise, prepPromise, micPromise, _b, accessToken, _c, postUrl, body, micStream_1, headers, res, json, wsUrl, roomCreatedSub_1, roomJoined, e_1, error_1;
1901
1903
  var _this = this;
1902
1904
  return __generator(this, function (_d) {
1903
1905
  switch (_d.label) {
@@ -1908,7 +1910,7 @@
1908
1910
  }
1909
1911
  _d.label = 1;
1910
1912
  case 1:
1911
- _d.trys.push([1, 6, , 8]);
1913
+ _d.trys.push([1, 10, , 12]);
1912
1914
  this.callStateSubject.next('connecting');
1913
1915
  this.statusTextSubject.next('Connecting...');
1914
1916
  tokenPromise = usersApiUrl && common.isPlatformBrowser(this.platformId)
@@ -1976,48 +1978,55 @@
1976
1978
  if (!wsUrl || typeof wsUrl !== 'string') {
1977
1979
  throw new Error('No ws_url in response');
1978
1980
  }
1979
- // Subscribe to room_created BEFORE connecting to avoid race
1980
- this.wsClient.roomCreated$
1981
- .pipe(operators.take(1), operators.takeUntil(this.destroy$))
1982
- .subscribe(function (roomUrl) { return __awaiter(_this, void 0, void 0, function () {
1983
- var err_1;
1984
- return __generator(this, function (_b) {
1985
- switch (_b.label) {
1986
- case 0:
1987
- _b.trys.push([0, 2, , 4]);
1988
- return [4 /*yield*/, this.onRoomCreated(roomUrl, micStream_1 !== null && micStream_1 !== void 0 ? micStream_1 : undefined)];
1989
- case 1:
1990
- _b.sent();
1991
- return [3 /*break*/, 4];
1992
- case 2:
1993
- err_1 = _b.sent();
1994
- console.error('Daily join failed:', err_1);
1995
- this.callStateSubject.next('ended');
1996
- this.statusTextSubject.next('Connection failed');
1997
- return [4 /*yield*/, this.disconnect()];
1998
- case 3:
1999
- _b.sent();
2000
- throw err_1;
2001
- case 4: return [2 /*return*/];
2002
- }
2003
- });
2004
- }); });
2005
- // Connect signaling WebSocket (no audio over WS)
2006
- return [4 /*yield*/, this.wsClient.connect(wsUrl)];
1981
+ roomJoined = new Promise(function (resolve, reject) {
1982
+ roomCreatedSub_1 = _this.wsClient.roomCreated$
1983
+ .pipe(operators.take(1), operators.takeUntil(_this.destroy$))
1984
+ .subscribe(function (roomUrl) { return __awaiter(_this, void 0, void 0, function () {
1985
+ var err_1;
1986
+ return __generator(this, function (_b) {
1987
+ switch (_b.label) {
1988
+ case 0:
1989
+ _b.trys.push([0, 2, , 3]);
1990
+ return [4 /*yield*/, this.onRoomCreated(roomUrl, micStream_1 !== null && micStream_1 !== void 0 ? micStream_1 : undefined)];
1991
+ case 1:
1992
+ _b.sent();
1993
+ resolve();
1994
+ return [3 /*break*/, 3];
1995
+ case 2:
1996
+ err_1 = _b.sent();
1997
+ console.error('Daily join failed:', err_1);
1998
+ reject(err_1);
1999
+ return [3 /*break*/, 3];
2000
+ case 3: return [2 /*return*/];
2001
+ }
2002
+ });
2003
+ }); }, function (err) { return reject(err); });
2004
+ });
2005
+ _d.label = 5;
2007
2006
  case 5:
2008
- // Connect signaling WebSocket (no audio over WS)
2009
- _d.sent();
2010
- return [3 /*break*/, 8];
2007
+ _d.trys.push([5, 8, , 9]);
2008
+ return [4 /*yield*/, this.wsClient.connect(wsUrl)];
2011
2009
  case 6:
2010
+ _d.sent();
2011
+ return [4 /*yield*/, roomJoined];
2012
+ case 7:
2013
+ _d.sent();
2014
+ return [3 /*break*/, 9];
2015
+ case 8:
2016
+ e_1 = _d.sent();
2017
+ roomCreatedSub_1 === null || roomCreatedSub_1 === void 0 ? void 0 : roomCreatedSub_1.unsubscribe();
2018
+ throw e_1;
2019
+ case 9: return [3 /*break*/, 12];
2020
+ case 10:
2012
2021
  error_1 = _d.sent();
2013
2022
  console.error('Error connecting voice agent:', error_1);
2014
2023
  this.callStateSubject.next('ended');
2015
2024
  return [4 /*yield*/, this.disconnect()];
2016
- case 7:
2025
+ case 11:
2017
2026
  _d.sent();
2018
2027
  this.statusTextSubject.next('Connection failed');
2019
2028
  throw error_1;
2020
- case 8: return [2 /*return*/];
2029
+ case 12: return [2 /*return*/];
2021
2030
  }
2022
2031
  });
2023
2032
  });