@anganyai/voice-sdk 0.0.5 → 0.0.7
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 +65 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +65 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -16423,6 +16423,15 @@ var SipManager = class extends EventEmitter {
|
|
|
16423
16423
|
}
|
|
16424
16424
|
const inviter = new Inviter(this.userAgent, uri, inviterOptions);
|
|
16425
16425
|
this.currentSession = inviter;
|
|
16426
|
+
let rejectionReason;
|
|
16427
|
+
inviter.delegate = {
|
|
16428
|
+
onReject: (response) => {
|
|
16429
|
+
const statusCode = response.message.statusCode;
|
|
16430
|
+
const reasonPhrase = response.message.reasonPhrase;
|
|
16431
|
+
this.logger.warn("Call rejected", { statusCode, reasonPhrase });
|
|
16432
|
+
rejectionReason = { code: statusCode, reason: this.mapSipErrorToMessage(statusCode, reasonPhrase) };
|
|
16433
|
+
}
|
|
16434
|
+
};
|
|
16426
16435
|
inviter.stateChange.addListener((state) => {
|
|
16427
16436
|
this.logger.debug("Call state changed", { state });
|
|
16428
16437
|
switch (state) {
|
|
@@ -16436,6 +16445,9 @@ var SipManager = class extends EventEmitter {
|
|
|
16436
16445
|
break;
|
|
16437
16446
|
case SessionState2.Terminated:
|
|
16438
16447
|
this.setState("registered");
|
|
16448
|
+
if (rejectionReason) {
|
|
16449
|
+
this.emit("error", new Error(rejectionReason.reason));
|
|
16450
|
+
}
|
|
16439
16451
|
this.emit("callEnded");
|
|
16440
16452
|
this.cleanupAudioResources();
|
|
16441
16453
|
delete this.currentSession;
|
|
@@ -16475,7 +16487,12 @@ var SipManager = class extends EventEmitter {
|
|
|
16475
16487
|
}
|
|
16476
16488
|
this.logger.info("\u{1F4F5} Hanging up call...");
|
|
16477
16489
|
try {
|
|
16478
|
-
this.currentSession.
|
|
16490
|
+
const sessionState = this.currentSession.state;
|
|
16491
|
+
if (sessionState === "Established" || sessionState === "Establishing") {
|
|
16492
|
+
this.currentSession.bye();
|
|
16493
|
+
} else {
|
|
16494
|
+
this.logger.debug("Session already terminated, skipping BYE", { state: sessionState });
|
|
16495
|
+
}
|
|
16479
16496
|
} catch (error) {
|
|
16480
16497
|
this.logger.warn("\u26A0\uFE0F Error sending BYE", { error });
|
|
16481
16498
|
}
|
|
@@ -16896,6 +16913,50 @@ var SipManager = class extends EventEmitter {
|
|
|
16896
16913
|
}
|
|
16897
16914
|
}, delay);
|
|
16898
16915
|
}
|
|
16916
|
+
/**
|
|
16917
|
+
* Map SIP error codes to user-friendly messages
|
|
16918
|
+
*/
|
|
16919
|
+
mapSipErrorToMessage(statusCode, reasonPhrase) {
|
|
16920
|
+
const errorMessages = {
|
|
16921
|
+
// 4xx Client Errors
|
|
16922
|
+
400: "Invalid request",
|
|
16923
|
+
401: "Authentication required",
|
|
16924
|
+
403: "Access denied",
|
|
16925
|
+
404: "Agent not found",
|
|
16926
|
+
408: "Request timeout",
|
|
16927
|
+
480: "Agent unavailable",
|
|
16928
|
+
486: "Agent is busy",
|
|
16929
|
+
487: "Call cancelled",
|
|
16930
|
+
488: "Not acceptable",
|
|
16931
|
+
// 5xx Server Errors
|
|
16932
|
+
500: "Server error",
|
|
16933
|
+
502: "Bad gateway",
|
|
16934
|
+
503: "Service unavailable",
|
|
16935
|
+
504: "Gateway timeout",
|
|
16936
|
+
// 6xx Global Failures
|
|
16937
|
+
600: "Agent is busy",
|
|
16938
|
+
603: "Agent declined the call",
|
|
16939
|
+
604: "Agent does not exist",
|
|
16940
|
+
606: "Not acceptable"
|
|
16941
|
+
};
|
|
16942
|
+
const message = errorMessages[statusCode];
|
|
16943
|
+
if (message) {
|
|
16944
|
+
return message;
|
|
16945
|
+
}
|
|
16946
|
+
if (reasonPhrase) {
|
|
16947
|
+
return reasonPhrase;
|
|
16948
|
+
}
|
|
16949
|
+
if (statusCode >= 400 && statusCode < 500) {
|
|
16950
|
+
return "Call failed";
|
|
16951
|
+
}
|
|
16952
|
+
if (statusCode >= 500 && statusCode < 600) {
|
|
16953
|
+
return "Server error";
|
|
16954
|
+
}
|
|
16955
|
+
if (statusCode >= 600) {
|
|
16956
|
+
return "Agent unavailable";
|
|
16957
|
+
}
|
|
16958
|
+
return "Unknown error";
|
|
16959
|
+
}
|
|
16899
16960
|
};
|
|
16900
16961
|
|
|
16901
16962
|
// src/services/TranscriptionService.ts
|
|
@@ -17440,7 +17501,9 @@ var Conversation = class extends EventEmitter {
|
|
|
17440
17501
|
}
|
|
17441
17502
|
}
|
|
17442
17503
|
if (!accessToken) {
|
|
17443
|
-
this.logger.info(
|
|
17504
|
+
this.logger.info(
|
|
17505
|
+
"No access token available - running in SIP-only mode (no transcription/API features)"
|
|
17506
|
+
);
|
|
17444
17507
|
} else {
|
|
17445
17508
|
this.accessToken = accessToken;
|
|
17446
17509
|
this.logger.debug("\u2713 Access token obtained for API calls", {
|