@anganyai/voice-sdk 0.0.4 → 0.0.6
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/dist/index.cjs +43 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +43 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -16475,7 +16475,12 @@ var SipManager = class extends EventEmitter {
|
|
|
16475
16475
|
}
|
|
16476
16476
|
this.logger.info("\u{1F4F5} Hanging up call...");
|
|
16477
16477
|
try {
|
|
16478
|
-
this.currentSession.
|
|
16478
|
+
const sessionState = this.currentSession.state;
|
|
16479
|
+
if (sessionState === "Established" || sessionState === "Establishing") {
|
|
16480
|
+
this.currentSession.bye();
|
|
16481
|
+
} else {
|
|
16482
|
+
this.logger.debug("Session already terminated, skipping BYE", { state: sessionState });
|
|
16483
|
+
}
|
|
16479
16484
|
} catch (error) {
|
|
16480
16485
|
this.logger.warn("\u26A0\uFE0F Error sending BYE", { error });
|
|
16481
16486
|
}
|
|
@@ -17420,27 +17425,35 @@ var Conversation = class extends EventEmitter {
|
|
|
17420
17425
|
throw new AuthenticationError("Not authenticated");
|
|
17421
17426
|
}
|
|
17422
17427
|
this.logger.debug("\u2713 Authentication check passed");
|
|
17423
|
-
this.logger.debug("=== STEP 2: GETTING ACCESS TOKEN ===");
|
|
17428
|
+
this.logger.debug("=== STEP 2: GETTING ACCESS TOKEN (OPTIONAL) ===");
|
|
17424
17429
|
let accessToken = authStatus.tokens?.accessToken;
|
|
17425
17430
|
this.logger.debug("OAuth access token", { hasOAuthToken: !!accessToken });
|
|
17426
17431
|
if (!accessToken) {
|
|
17427
17432
|
this.logger.debug("No OAuth access token in auth status, trying to get from AuthManager");
|
|
17428
|
-
|
|
17433
|
+
try {
|
|
17434
|
+
accessToken = await this.authManager.getAccessToken();
|
|
17435
|
+
} catch {
|
|
17436
|
+
}
|
|
17429
17437
|
this.logger.debug("Access token from AuthManager", { hasToken: !!accessToken });
|
|
17430
17438
|
}
|
|
17431
17439
|
if (!accessToken) {
|
|
17432
|
-
this.logger.
|
|
17433
|
-
|
|
17434
|
-
|
|
17435
|
-
|
|
17436
|
-
|
|
17437
|
-
|
|
17440
|
+
this.logger.debug("No OAuth access token, checking ephemeral credentials for API token");
|
|
17441
|
+
const cachedCreds = this.authManager.getCachedEphemeralCredentials();
|
|
17442
|
+
if (cachedCreds?.apiToken) {
|
|
17443
|
+
accessToken = cachedCreds.apiToken;
|
|
17444
|
+
this.logger.debug("Using API token from ephemeral credentials");
|
|
17445
|
+
}
|
|
17446
|
+
}
|
|
17447
|
+
if (!accessToken) {
|
|
17448
|
+
this.logger.info(
|
|
17449
|
+
"No access token available - running in SIP-only mode (no transcription/API features)"
|
|
17438
17450
|
);
|
|
17451
|
+
} else {
|
|
17452
|
+
this.accessToken = accessToken;
|
|
17453
|
+
this.logger.debug("\u2713 Access token obtained for API calls", {
|
|
17454
|
+
tokenLength: accessToken.length
|
|
17455
|
+
});
|
|
17439
17456
|
}
|
|
17440
|
-
this.accessToken = accessToken;
|
|
17441
|
-
this.logger.debug("\u2713 Access token obtained for API calls", {
|
|
17442
|
-
tokenLength: accessToken.length
|
|
17443
|
-
});
|
|
17444
17457
|
this.logger.debug("=== STEP 3: ENSURING EPHEMERAL CREDENTIALS ===");
|
|
17445
17458
|
if (!this.ephemeralCredentials) {
|
|
17446
17459
|
this.logger.debug("Getting ephemeral credentials");
|
|
@@ -17549,19 +17562,23 @@ var Conversation = class extends EventEmitter {
|
|
|
17549
17562
|
this.setupSipHandlers();
|
|
17550
17563
|
this.logger.debug("Registering with SIP server");
|
|
17551
17564
|
await this.sipManager.register();
|
|
17552
|
-
this.
|
|
17553
|
-
this.
|
|
17554
|
-
|
|
17555
|
-
|
|
17556
|
-
|
|
17557
|
-
|
|
17558
|
-
|
|
17559
|
-
|
|
17560
|
-
|
|
17561
|
-
|
|
17562
|
-
|
|
17563
|
-
|
|
17564
|
-
|
|
17565
|
+
if (this.accessToken) {
|
|
17566
|
+
this.transcriptionService.setTokenRefreshCallback(async () => {
|
|
17567
|
+
this.logger.debug("TranscriptionService requesting fresh token");
|
|
17568
|
+
const freshToken = await this.authManager.getAccessToken();
|
|
17569
|
+
if (!freshToken) {
|
|
17570
|
+
throw new Error("Unable to get fresh access token");
|
|
17571
|
+
}
|
|
17572
|
+
this.accessToken = freshToken;
|
|
17573
|
+
this.logger.debug("Fresh token provided to TranscriptionService");
|
|
17574
|
+
return freshToken;
|
|
17575
|
+
});
|
|
17576
|
+
this.logger.debug("Starting transcription stream");
|
|
17577
|
+
await this.transcriptionService.start(this.accessToken);
|
|
17578
|
+
this.setupTranscriptionHandlers();
|
|
17579
|
+
} else {
|
|
17580
|
+
this.logger.info("Skipping transcription service - no access token available");
|
|
17581
|
+
}
|
|
17565
17582
|
this.logger.debug("Making call to resource", { resourceId: this.options.resource });
|
|
17566
17583
|
const callOptions = {
|
|
17567
17584
|
resourceId: this.options.resource,
|