@telnyx/ai-agent-lib 0.4.0-beta.1 → 0.4.0
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.js +339 -333
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _t, { useReducer as
|
|
1
|
+
import _t, { useReducer as Gn, useEffect as ve, useDebugValue as Vn, useCallback as qn, useContext as on, createContext as rn, useState as Yn } from "react";
|
|
2
2
|
function He(n, e) {
|
|
3
3
|
var t = {};
|
|
4
4
|
for (var i in n) Object.prototype.hasOwnProperty.call(n, i) && e.indexOf(i) < 0 && (t[i] = n[i]);
|
|
@@ -33,10 +33,10 @@ function O(n, e, t, i) {
|
|
|
33
33
|
u((i = i.apply(n, [])).next());
|
|
34
34
|
}));
|
|
35
35
|
}
|
|
36
|
-
var wt = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto < "u" && typeof msCrypto.getRandomValues == "function" && msCrypto.getRandomValues.bind(msCrypto),
|
|
36
|
+
var wt = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto < "u" && typeof msCrypto.getRandomValues == "function" && msCrypto.getRandomValues.bind(msCrypto), Jn = new Uint8Array(16);
|
|
37
37
|
function Kn() {
|
|
38
38
|
if (!wt) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
39
|
-
return wt(
|
|
39
|
+
return wt(Jn);
|
|
40
40
|
}
|
|
41
41
|
for (var an = [], Me = 0; Me < 256; ++Me) an[Me] = (Me + 256).toString(16).substr(1);
|
|
42
42
|
function ye(n, e, t) {
|
|
@@ -49,14 +49,14 @@ function ye(n, e, t) {
|
|
|
49
49
|
return [l[r[u++]], l[r[u++]], l[r[u++]], l[r[u++]], "-", l[r[u++]], l[r[u++]], "-", l[r[u++]], l[r[u++]], "-", l[r[u++]], l[r[u++]], "-", l[r[u++]], l[r[u++]], l[r[u++]], l[r[u++]], l[r[u++]], l[r[u++]]].join("");
|
|
50
50
|
})(s);
|
|
51
51
|
}
|
|
52
|
-
const
|
|
52
|
+
const zn = { SDP_CREATE_OFFER_FAILED: 40001, SDP_CREATE_ANSWER_FAILED: 40002, SDP_SET_LOCAL_DESCRIPTION_FAILED: 40003, SDP_SET_REMOTE_DESCRIPTION_FAILED: 40004, SDP_SEND_FAILED: 40005, MEDIA_MICROPHONE_PERMISSION_DENIED: 42001, MEDIA_DEVICE_NOT_FOUND: 42002, MEDIA_GET_USER_MEDIA_FAILED: 42003, HOLD_FAILED: 44001, INVALID_CALL_PARAMETERS: 44002, BYE_SEND_FAILED: 44003, SUBSCRIBE_FAILED: 44004, WEBSOCKET_CONNECTION_FAILED: 45001, WEBSOCKET_ERROR: 45002, RECONNECTION_EXHAUSTED: 45003, GATEWAY_FAILED: 45004, LOGIN_FAILED: 46001, INVALID_CREDENTIALS: 46002, AUTHENTICATION_REQUIRED: 46003, NETWORK_OFFLINE: 48001, UNEXPECTED_ERROR: 49001 }, Qn = { HIGH_RTT: 31001, HIGH_JITTER: 31002, HIGH_PACKET_LOSS: 31003, LOW_MOS: 31004, LOW_BYTES_RECEIVED: 32001, LOW_BYTES_SENT: 32002, ICE_CONNECTIVITY_LOST: 33001, ICE_GATHERING_TIMEOUT: 33002, ICE_GATHERING_EMPTY: 33003, PEER_CONNECTION_FAILED: 33004, ONLY_HOST_ICE_CANDIDATES: 33005, TOKEN_EXPIRING_SOON: 34001, SESSION_NOT_REATTACHED: 35001 }, { SDP_CREATE_OFFER_FAILED: Xn, SDP_CREATE_ANSWER_FAILED: Zn, SDP_SET_LOCAL_DESCRIPTION_FAILED: ei, SDP_SET_REMOTE_DESCRIPTION_FAILED: cn, SDP_SEND_FAILED: Et, MEDIA_MICROPHONE_PERMISSION_DENIED: ti, MEDIA_DEVICE_NOT_FOUND: ni, MEDIA_GET_USER_MEDIA_FAILED: ln, HOLD_FAILED: ii, INVALID_CALL_PARAMETERS: si, BYE_SEND_FAILED: oi, SUBSCRIBE_FAILED: ri, WEBSOCKET_CONNECTION_FAILED: ai, WEBSOCKET_ERROR: ci, RECONNECTION_EXHAUSTED: li, GATEWAY_FAILED: di, LOGIN_FAILED: dn, INVALID_CREDENTIALS: ui, AUTHENTICATION_REQUIRED: hi, NETWORK_OFFLINE: pi, UNEXPECTED_ERROR: It } = zn, { HIGH_RTT: fi, HIGH_JITTER: gi, HIGH_PACKET_LOSS: vi, LOW_MOS: Tt, LOW_BYTES_RECEIVED: mi, LOW_BYTES_SENT: _i, ICE_CONNECTIVITY_LOST: yi, ICE_GATHERING_TIMEOUT: Si, ICE_GATHERING_EMPTY: bi, PEER_CONNECTION_FAILED: Ci, ONLY_HOST_ICE_CANDIDATES: wi, TOKEN_EXPIRING_SOON: Ei, SESSION_NOT_REATTACHED: Ii } = Qn, Ti = /^a=candidate:.+typ (srflx|prflx|relay)/m, kt = "wss://rtc.telnyx.com", ki = 1006, un = { urls: "stun:stun.l.google.com:19302" }, Ri = [{ urls: "stun:stun.telnyx.com:3478" }, un, { urls: "turn:turn.telnyx.com:3478?transport=udp", username: "testuser", credential: "testpassword" }, { urls: "turn:turn.telnyx.com:3478?transport=tcp", username: "testuser", credential: "testpassword" }], Ai = [{ urls: "stun:stundev.telnyx.com:3478" }, un, { urls: "turn:turndev.telnyx.com:3478?transport=udp", username: "testuser", credential: "testpassword" }, { urls: "turn:turndev.telnyx.com:3478?transport=tcp", username: "testuser", credential: "testpassword" }];
|
|
53
53
|
var T;
|
|
54
54
|
(function(n) {
|
|
55
55
|
n.SocketOpen = "telnyx.socket.open", n.SocketClose = "telnyx.socket.close", n.SocketError = "telnyx.socket.error", n.SocketMessage = "telnyx.socket.message", n.SpeedTest = "telnyx.internal.speedtest", n.Ready = "telnyx.ready", n.Error = "telnyx.error", n.Warning = "telnyx.warning", n.Notification = "telnyx.notification", n.StatsFrame = "telnyx.stats.frame", n.StatsReport = "telnyx.stats.report", n.Messages = "telnyx.messages", n.Calls = "telnyx.calls", n.MediaError = "telnyx.rtc.mediaError", n.PeerConnectionFailureError = "telnyx.rtc.peerConnectionFailureError", n.PeerConnectionSignalingStateClosed = "telnyx.rtc.peerConnectionSignalingStateClosed";
|
|
56
56
|
})(T || (T = {}));
|
|
57
|
-
const Ai = { 40001: { name: "SDP_CREATE_OFFER_FAILED", message: "Failed to create call offer", description: "The browser was unable to generate a local SDP offer. This typically indicates a WebRTC API error or invalid media constraints.", causes: ["Browser WebRTC API error", "Missing or invalid media constraints"], solutions: ["Check getUserMedia permissions", "Verify ICE server configuration"] }, 40002: { name: "SDP_CREATE_ANSWER_FAILED", message: "Failed to answer the call", description: "The browser was unable to generate a local SDP answer. The remote offer may be invalid or the browser state inconsistent.", causes: ["Browser WebRTC API error", "Invalid remote SDP offer"], solutions: ["Retry the call", "Check browser WebRTC compatibility"] }, 40003: { name: "SDP_SET_LOCAL_DESCRIPTION_FAILED", message: "Failed to apply local call settings", description: "setLocalDescription() was rejected by the browser. The generated SDP may be malformed or the browser state may be inconsistent.", causes: ["Malformed SDP", "Browser state inconsistency"], solutions: ["Retry the call"] }, 40004: { name: "SDP_SET_REMOTE_DESCRIPTION_FAILED", message: "Failed to apply remote call settings", description: "setRemoteDescription() was rejected by the browser. The remote SDP may be malformed or contain unsupported codecs.", causes: ["Malformed remote SDP", "Browser codec mismatch"], solutions: ["Retry the call", "Check codec configuration"] }, 40005: { name: "SDP_SEND_FAILED", message: "Failed to send call data to server", description: "The Invite or Answer message could not be delivered via the signaling WebSocket. The connection may have been lost.", causes: ["WebSocket connection lost", "Server error"], solutions: ["Check network connectivity", "Retry the call"] }, 42001: { name: "MEDIA_MICROPHONE_PERMISSION_DENIED", message: "Microphone access denied", description: "The user or operating system denied microphone permission. The browser permission prompt was dismissed or OS-level access is disabled.", causes: ["User denied browser permission prompt", "OS-level microphone access disabled"], solutions: ["Ask user to grant microphone permission in browser settings"] }, 42002: { name: "MEDIA_DEVICE_NOT_FOUND", message: "No microphone found", description: "The requested audio input device is not available. No microphone is connected, the device was disconnected, or an invalid deviceId was specified.", causes: ["No microphone connected", "Device was disconnected", "Invalid deviceId"], solutions: ["Check that a microphone is connected", "Select a valid audio input device"] }, 42003: { name: "MEDIA_GET_USER_MEDIA_FAILED", message: "Failed to access microphone", description: "getUserMedia() was rejected for an unexpected reason. The device may be in use by another application or the browser encountered an internal error.", causes: ["Browser error", "Device in use by another application"], solutions: ["Close other applications using the microphone", "Retry"] }, 44001: { name: "HOLD_FAILED", message: "Failed to hold the call", description: "The server rejected or did not respond to the hold request. The WebSocket connection may have been lost during the operation.", causes: ["Server error", "WebSocket connection lost during hold"], solutions: ["Retry the hold operation", "Check network connectivity"] }, 44002: { name: "INVALID_CALL_PARAMETERS", message: "Invalid call parameters", description: "The call could not be initiated because required parameters are missing or invalid. For example, no destination number was provided to newCall().", causes: ["Missing destinationNumber in call options", "Invalid or empty call parameters"], solutions: ["Provide a valid destinationNumber when calling newCall()", "Check the call options object for required fields"] }, 44003: { name: "BYE_SEND_FAILED", message: "Failed to hang up cleanly", description: "The hangup signal could not be delivered to the server. The call was terminated locally but the server may not be aware.", causes: ["WebSocket connection lost before BYE sent"], solutions: ["No action needed — call is terminated locally", "Check network connectivity"] }, 44004: { name: "SUBSCRIBE_FAILED", message: "Failed to subscribe to call events", description: "The Verto subscribe request for the call channel failed. This may prevent receiving call state updates from the server.", causes: ["WebSocket connection lost during subscribe", "Server rejected the subscription request"], solutions: ["Check network connectivity", "Retry the call"] }, 45001: { name: "WEBSOCKET_CONNECTION_FAILED", message: "Unable to connect to server", description: "The WebSocket connection to the signaling server could not be established. The server may be unreachable, the URL may be incorrect, or a firewall may be blocking the connection.", causes: ["Server unreachable", "Incorrect WebSocket URL", "Firewall blocking WebSocket connections", "Network interruption"], solutions: ["Check network connectivity", "Verify the signaling server URL", "Ensure WebSocket connections are not blocked by a firewall"] }, 45002: { name: "WEBSOCKET_ERROR", message: "Connection to server lost", description: "An error occurred on the WebSocket connection after it was established. The connection may have been dropped due to network issues or server-side closure.", causes: ["Network interruption", "Server closed the connection", "Idle timeout"], solutions: ["Check network connectivity", "SDK will attempt automatic reconnection if configured"] }, 45003: { name: "RECONNECTION_EXHAUSTED", message: "Unable to reconnect to server", description: "All automatic reconnection attempts have been exhausted. The SDK tried to re-establish the WebSocket connection multiple times but failed on every attempt.", causes: ["Prolonged network outage", "Server unreachable", "Firewall or proxy blocking reconnection"], solutions: ["Check network connectivity", "Call client.disconnect() and client.connect() to manually retry", "Notify the user that the connection was lost"] }, 45004: { name: "GATEWAY_FAILED", message: "Gateway connection failed", description: "The upstream gateway reported a FAILED or FAIL_WAIT state. The signaling server could not establish or maintain a connection to the gateway. When autoReconnect is disabled, this is immediately fatal. When enabled, the SDK will retry until RECONNECTION_EXHAUSTED.", causes: ["Gateway down or unreachable", "Server-side infrastructure issue", "Network partition between signaling server and gateway"], solutions: ["Wait for automatic reconnection (if autoReconnect is enabled)", "Call client.disconnect() and client.connect() to manually retry", "Check Telnyx service status"] }, 46001: { name: "LOGIN_FAILED", message: "Authentication failed", description: "The login request was rejected by the server. The credentials may be invalid, expired, or the account may be suspended.", causes: ["Invalid credentials (username/password or token)", "Expired authentication token", "Account suspended or disabled"], solutions: ["Verify credentials", "Generate a new authentication token", "Check account status"] }, 46002: { name: "INVALID_CREDENTIALS", message: "Invalid credential parameters", description: "The SDK rejected the login options before sending any request to the server. This is an internal client-side validation guard — the credentials object is missing required fields or has an invalid structure. No network request was made.", causes: ["Missing login and password fields", "Missing or malformed authentication token", "Invalid combination of credential fields in the options object"], solutions: ["Provide valid login/password or a valid authentication token", "Check the TelnyxRTC constructor options against the documentation", "Ensure the credential object matches one of the supported auth modes (credentials, token, or anonymous)"] }, 46003: { name: "AUTHENTICATION_REQUIRED", message: "Authentication required", description: "The server rejected a request because the session is not authenticated. This can happen when the client sends a message (e.g. Invite, Subscribe, or Ping) before login completes, after a token expires mid-session, or after the server drops the authenticated state for any reason.", causes: ["Message sent before login completed", "Authentication token expired during the session", "Server-side session was invalidated", "WebSocket reconnected but re-authentication did not complete"], solutions: ["Ensure the client is fully logged in before sending messages", "Re-authenticate using client.login() with fresh credentials", "Listen for telnyx.ready before making calls or sending requests"] }, 48001: { name: "NETWORK_OFFLINE", message: "Device is offline", description: "The browser reported that the device has lost network connectivity (navigator.onLine === false). All WebSocket and media connections will fail until the network is restored.", causes: ["Wi-Fi or ethernet disconnected", "Airplane mode enabled", "Network interface went down"], solutions: ["Check network connectivity", "Reconnect to Wi-Fi or ethernet", "Disable airplane mode"] }, 49001: { name: "UNEXPECTED_ERROR", message: "An unexpected error occurred", description: "An error was thrown that does not match any known SDK error category. This is a catch-all for unclassified failures.", causes: ["Unknown or unhandled error condition"], solutions: ["Check the originalError property for the underlying cause", "Report the issue if it persists"] } }, Oi = { 31001: { name: "HIGH_RTT", message: "High network latency detected", description: "Round-trip time (RTT) exceeded the threshold for multiple consecutive samples. High latency causes perceptible audio delays.", causes: ["Poor network connection", "Geographic distance to media server", "Network congestion"], solutions: ["Check network connectivity", "Use a wired connection instead of Wi-Fi", "Close bandwidth-heavy applications"] }, 31002: { name: "HIGH_JITTER", message: "High jitter detected", description: "Jitter (variability in packet arrival time) exceeded the threshold for multiple consecutive samples. High jitter causes crackling and choppy audio.", causes: ["Network congestion", "Unstable Wi-Fi connection", "Overloaded network equipment"], solutions: ["Use a wired connection instead of Wi-Fi", "Close bandwidth-heavy applications", "Check network equipment"] }, 31003: { name: "HIGH_PACKET_LOSS", message: "High packet loss detected", description: "Packet loss exceeded the threshold for multiple consecutive samples. High packet loss causes choppy audio or dropped calls.", causes: ["Network congestion", "Unstable connection", "Firewall or QoS misconfiguration"], solutions: ["Check network connectivity", "Use a wired connection", "Contact network administrator"] }, 31004: { name: "LOW_MOS", message: "Low call quality score", description: "Mean Opinion Score (MOS) dropped below the acceptable threshold for multiple consecutive samples. This is a composite indicator of overall call quality.", causes: ["Combination of high latency, jitter, and/or packet loss", "Poor network conditions"], solutions: ["Check network connectivity", "Use a wired connection", "Close bandwidth-heavy applications"] }, 32001: { name: "LOW_BYTES_RECEIVED", message: "No audio data received", description: "No bytes have been received from the remote party for multiple consecutive seconds. This may indicate a network interruption or remote-side issue.", causes: ["Network interruption", "Remote party microphone issue", "Firewall blocking inbound media"], solutions: ["Check network connectivity", "Ask remote party to check their microphone", "Check firewall rules for media ports"] }, 32002: { name: "LOW_BYTES_SENT", message: "No audio data being sent", description: "No bytes have been sent for multiple consecutive seconds. This may indicate a local microphone issue or network interruption.", causes: ["Microphone muted or disconnected", "Network interruption", "Local media track ended"], solutions: ["Check that the microphone is not muted", "Verify the microphone is still connected", "Check network connectivity"] }, 33001: { name: "ICE_CONNECTIVITY_LOST", message: "Connection interrupted", description: "The ICE connection transitioned to the disconnected state. The previously selected connection path was lost and renegotiation may be required. The connection may recover automatically.", causes: ["Temporary network interruption", "Network interface change (e.g. Wi-Fi to cellular)", "NAT rebinding"], solutions: ["Wait for automatic recovery", "Check network connectivity"] }, 33002: { name: "ICE_GATHERING_TIMEOUT", message: "ICE gathering timed out", description: "ICE candidate gathering did not complete within the safety timeout. This is typically caused by network restrictions blocking STUN/TURN. The call may still succeed if candidates arrive late.", causes: ["Firewall blocking STUN/TURN", "Network unreachable", "STUN/TURN server not responding"], solutions: ["Check STUN/TURN server reachability", "Ensure UDP traffic is not blocked", "Try forceRelayCandidate option"] }, 33003: { name: "ICE_GATHERING_EMPTY", message: "No ICE candidates gathered", description: "No ICE candidates were gathered after sending the initial SDP. This may indicate a firewall blocking all STUN/TURN traffic or no available network interface.", causes: ["Firewall blocking all STUN/TURN traffic", "No network interface available", "VPN blocking UDP"], solutions: ["Check STUN/TURN server reachability", "Ensure UDP traffic is not blocked", "Use forceRelayCandidate option"] }, 33004: { name: "PEER_CONNECTION_FAILED", message: "Connection failed", description: "RTCPeerConnection entered the failed state. This is a recoverable condition — the SDK may attempt ICE restart or the connection may recover. If it does not recover, the call will eventually be terminated.", causes: ["ICE failure", "DTLS handshake failure", "Prolonged network interruption"], solutions: ["Wait for automatic recovery", "Check network connectivity", "Verify TURN server credentials"] }, 33005: { name: "ONLY_HOST_ICE_CANDIDATES", message: "Only local network candidates available", description: "ICE gathering completed but only host (local network) candidates were collected — no server-reflexive (srflx) or relay (turn) candidates were found. This typically means the STUN/TURN servers are unreachable, which will prevent connections outside the local network.", causes: ["STUN/TURN servers unreachable", "Firewall blocking UDP traffic to STUN/TURN servers", "Incorrect TURN server configuration or credentials", "Restrictive corporate network or VPN"], solutions: ["Verify STUN/TURN server URLs and credentials", "Ensure UDP traffic to STUN/TURN ports is not blocked", "Check firewall or VPN settings", "Try using TCP-based TURN as a fallback"] }, 34001: { name: "TOKEN_EXPIRING_SOON", message: "Authentication token expiring soon", description: "The authentication token is approaching its expiration time. If the token expires the connection will be lost and calls will fail. A new token should be generated before expiration.", causes: ["Token was issued with a limited lifetime"], solutions: ["Generate a new authentication token", "Reconnect with fresh credentials before the token expires"] }, 35001: { name: "SESSION_NOT_REATTACHED", message: "Active call lost after reconnect", description: "The WebSocket reconnected successfully but the server returned an empty reattached_sessions list while the SDK still has an active call. The server no longer knows about the call, so any subsequent call-control operation (hangup, hold, etc.) will fail with CALL_DOES_NOT_EXIST.", causes: ["Server-side session expired during the disconnection window", "Reconnect token was invalidated", "Backend restarted or lost in-memory call state"], solutions: ["Terminate the local call and notify the user", "Start a new call", "Investigate why the session was not preserved on the server"] } };
|
|
57
|
+
const Oi = { 40001: { name: "SDP_CREATE_OFFER_FAILED", message: "Failed to create call offer", description: "The browser was unable to generate a local SDP offer. This typically indicates a WebRTC API error or invalid media constraints.", causes: ["Browser WebRTC API error", "Missing or invalid media constraints"], solutions: ["Check getUserMedia permissions", "Verify ICE server configuration"] }, 40002: { name: "SDP_CREATE_ANSWER_FAILED", message: "Failed to answer the call", description: "The browser was unable to generate a local SDP answer. The remote offer may be invalid or the browser state inconsistent.", causes: ["Browser WebRTC API error", "Invalid remote SDP offer"], solutions: ["Retry the call", "Check browser WebRTC compatibility"] }, 40003: { name: "SDP_SET_LOCAL_DESCRIPTION_FAILED", message: "Failed to apply local call settings", description: "setLocalDescription() was rejected by the browser. The generated SDP may be malformed or the browser state may be inconsistent.", causes: ["Malformed SDP", "Browser state inconsistency"], solutions: ["Retry the call"] }, 40004: { name: "SDP_SET_REMOTE_DESCRIPTION_FAILED", message: "Failed to apply remote call settings", description: "setRemoteDescription() was rejected by the browser. The remote SDP may be malformed or contain unsupported codecs.", causes: ["Malformed remote SDP", "Browser codec mismatch"], solutions: ["Retry the call", "Check codec configuration"] }, 40005: { name: "SDP_SEND_FAILED", message: "Failed to send call data to server", description: "The Invite or Answer message could not be delivered via the signaling WebSocket. The connection may have been lost.", causes: ["WebSocket connection lost", "Server error"], solutions: ["Check network connectivity", "Retry the call"] }, 42001: { name: "MEDIA_MICROPHONE_PERMISSION_DENIED", message: "Microphone access denied", description: "The user or operating system denied microphone permission. The browser permission prompt was dismissed or OS-level access is disabled.", causes: ["User denied browser permission prompt", "OS-level microphone access disabled"], solutions: ["Ask user to grant microphone permission in browser settings"] }, 42002: { name: "MEDIA_DEVICE_NOT_FOUND", message: "No microphone found", description: "The requested audio input device is not available. No microphone is connected, the device was disconnected, or an invalid deviceId was specified.", causes: ["No microphone connected", "Device was disconnected", "Invalid deviceId"], solutions: ["Check that a microphone is connected", "Select a valid audio input device"] }, 42003: { name: "MEDIA_GET_USER_MEDIA_FAILED", message: "Failed to access microphone", description: "getUserMedia() was rejected for an unexpected reason. The device may be in use by another application or the browser encountered an internal error.", causes: ["Browser error", "Device in use by another application"], solutions: ["Close other applications using the microphone", "Retry"] }, 44001: { name: "HOLD_FAILED", message: "Failed to hold the call", description: "The server rejected or did not respond to the hold request. The WebSocket connection may have been lost during the operation.", causes: ["Server error", "WebSocket connection lost during hold"], solutions: ["Retry the hold operation", "Check network connectivity"] }, 44002: { name: "INVALID_CALL_PARAMETERS", message: "Invalid call parameters", description: "The call could not be initiated because required parameters are missing or invalid. For example, no destination number was provided to newCall().", causes: ["Missing destinationNumber in call options", "Invalid or empty call parameters"], solutions: ["Provide a valid destinationNumber when calling newCall()", "Check the call options object for required fields"] }, 44003: { name: "BYE_SEND_FAILED", message: "Failed to hang up cleanly", description: "The hangup signal could not be delivered to the server. The call was terminated locally but the server may not be aware.", causes: ["WebSocket connection lost before BYE sent"], solutions: ["No action needed — call is terminated locally", "Check network connectivity"] }, 44004: { name: "SUBSCRIBE_FAILED", message: "Failed to subscribe to call events", description: "The Verto subscribe request for the call channel failed. This may prevent receiving call state updates from the server.", causes: ["WebSocket connection lost during subscribe", "Server rejected the subscription request"], solutions: ["Check network connectivity", "Retry the call"] }, 45001: { name: "WEBSOCKET_CONNECTION_FAILED", message: "Unable to connect to server", description: "The WebSocket connection to the signaling server could not be established. The server may be unreachable, the URL may be incorrect, or a firewall may be blocking the connection.", causes: ["Server unreachable", "Incorrect WebSocket URL", "Firewall blocking WebSocket connections", "Network interruption"], solutions: ["Check network connectivity", "Verify the signaling server URL", "Ensure WebSocket connections are not blocked by a firewall"] }, 45002: { name: "WEBSOCKET_ERROR", message: "Connection to server lost", description: "An error occurred on the WebSocket connection after it was established. The connection may have been dropped due to network issues or server-side closure.", causes: ["Network interruption", "Server closed the connection", "Idle timeout"], solutions: ["Check network connectivity", "SDK will attempt automatic reconnection if configured"] }, 45003: { name: "RECONNECTION_EXHAUSTED", message: "Unable to reconnect to server", description: "All automatic reconnection attempts have been exhausted. The SDK tried to re-establish the WebSocket connection multiple times but failed on every attempt.", causes: ["Prolonged network outage", "Server unreachable", "Firewall or proxy blocking reconnection"], solutions: ["Check network connectivity", "Call client.disconnect() and client.connect() to manually retry", "Notify the user that the connection was lost"] }, 45004: { name: "GATEWAY_FAILED", message: "Gateway connection failed", description: "The upstream gateway reported a FAILED or FAIL_WAIT state. The signaling server could not establish or maintain a connection to the gateway. When autoReconnect is disabled, this is immediately fatal. When enabled, the SDK will retry until RECONNECTION_EXHAUSTED.", causes: ["Gateway down or unreachable", "Server-side infrastructure issue", "Network partition between signaling server and gateway"], solutions: ["Wait for automatic reconnection (if autoReconnect is enabled)", "Call client.disconnect() and client.connect() to manually retry", "Check Telnyx service status"] }, 46001: { name: "LOGIN_FAILED", message: "Authentication failed", description: "The login request was rejected by the server. The credentials may be invalid, expired, or the account may be suspended.", causes: ["Invalid credentials (username/password or token)", "Expired authentication token", "Account suspended or disabled"], solutions: ["Verify credentials", "Generate a new authentication token", "Check account status"] }, 46002: { name: "INVALID_CREDENTIALS", message: "Invalid credential parameters", description: "The SDK rejected the login options before sending any request to the server. This is an internal client-side validation guard — the credentials object is missing required fields or has an invalid structure. No network request was made.", causes: ["Missing login and password fields", "Missing or malformed authentication token", "Invalid combination of credential fields in the options object"], solutions: ["Provide valid login/password or a valid authentication token", "Check the TelnyxRTC constructor options against the documentation", "Ensure the credential object matches one of the supported auth modes (credentials, token, or anonymous)"] }, 46003: { name: "AUTHENTICATION_REQUIRED", message: "Authentication required", description: "The server rejected a request because the session is not authenticated. This can happen when the client sends a message (e.g. Invite, Subscribe, or Ping) before login completes, after a token expires mid-session, or after the server drops the authenticated state for any reason.", causes: ["Message sent before login completed", "Authentication token expired during the session", "Server-side session was invalidated", "WebSocket reconnected but re-authentication did not complete"], solutions: ["Ensure the client is fully logged in before sending messages", "Re-authenticate using client.login() with fresh credentials", "Listen for telnyx.ready before making calls or sending requests"] }, 48001: { name: "NETWORK_OFFLINE", message: "Device is offline", description: "The browser reported that the device has lost network connectivity (navigator.onLine === false). All WebSocket and media connections will fail until the network is restored.", causes: ["Wi-Fi or ethernet disconnected", "Airplane mode enabled", "Network interface went down"], solutions: ["Check network connectivity", "Reconnect to Wi-Fi or ethernet", "Disable airplane mode"] }, 49001: { name: "UNEXPECTED_ERROR", message: "An unexpected error occurred", description: "An error was thrown that does not match any known SDK error category. This is a catch-all for unclassified failures.", causes: ["Unknown or unhandled error condition"], solutions: ["Check the originalError property for the underlying cause", "Report the issue if it persists"] } }, Li = { 31001: { name: "HIGH_RTT", message: "High network latency detected", description: "Round-trip time (RTT) exceeded the threshold for multiple consecutive samples. High latency causes perceptible audio delays.", causes: ["Poor network connection", "Geographic distance to media server", "Network congestion"], solutions: ["Check network connectivity", "Use a wired connection instead of Wi-Fi", "Close bandwidth-heavy applications"] }, 31002: { name: "HIGH_JITTER", message: "High jitter detected", description: "Jitter (variability in packet arrival time) exceeded the threshold for multiple consecutive samples. High jitter causes crackling and choppy audio.", causes: ["Network congestion", "Unstable Wi-Fi connection", "Overloaded network equipment"], solutions: ["Use a wired connection instead of Wi-Fi", "Close bandwidth-heavy applications", "Check network equipment"] }, 31003: { name: "HIGH_PACKET_LOSS", message: "High packet loss detected", description: "Packet loss exceeded the threshold for multiple consecutive samples. High packet loss causes choppy audio or dropped calls.", causes: ["Network congestion", "Unstable connection", "Firewall or QoS misconfiguration"], solutions: ["Check network connectivity", "Use a wired connection", "Contact network administrator"] }, 31004: { name: "LOW_MOS", message: "Low call quality score", description: "Mean Opinion Score (MOS) dropped below the acceptable threshold for multiple consecutive samples. This is a composite indicator of overall call quality.", causes: ["Combination of high latency, jitter, and/or packet loss", "Poor network conditions"], solutions: ["Check network connectivity", "Use a wired connection", "Close bandwidth-heavy applications"] }, 32001: { name: "LOW_BYTES_RECEIVED", message: "No audio data received", description: "No bytes have been received from the remote party for multiple consecutive seconds. This may indicate a network interruption or remote-side issue.", causes: ["Network interruption", "Remote party microphone issue", "Firewall blocking inbound media"], solutions: ["Check network connectivity", "Ask remote party to check their microphone", "Check firewall rules for media ports"] }, 32002: { name: "LOW_BYTES_SENT", message: "No audio data being sent", description: "No bytes have been sent for multiple consecutive seconds. This may indicate a local microphone issue or network interruption.", causes: ["Microphone muted or disconnected", "Network interruption", "Local media track ended"], solutions: ["Check that the microphone is not muted", "Verify the microphone is still connected", "Check network connectivity"] }, 33001: { name: "ICE_CONNECTIVITY_LOST", message: "Connection interrupted", description: "The ICE connection transitioned to the disconnected state. The previously selected connection path was lost and renegotiation may be required. The connection may recover automatically.", causes: ["Temporary network interruption", "Network interface change (e.g. Wi-Fi to cellular)", "NAT rebinding"], solutions: ["Wait for automatic recovery", "Check network connectivity"] }, 33002: { name: "ICE_GATHERING_TIMEOUT", message: "ICE gathering timed out", description: "ICE candidate gathering did not complete within the safety timeout. This is typically caused by network restrictions blocking STUN/TURN. The call may still succeed if candidates arrive late.", causes: ["Firewall blocking STUN/TURN", "Network unreachable", "STUN/TURN server not responding"], solutions: ["Check STUN/TURN server reachability", "Ensure UDP traffic is not blocked", "Try forceRelayCandidate option"] }, 33003: { name: "ICE_GATHERING_EMPTY", message: "No ICE candidates gathered", description: "No ICE candidates were gathered after sending the initial SDP. This may indicate a firewall blocking all STUN/TURN traffic or no available network interface.", causes: ["Firewall blocking all STUN/TURN traffic", "No network interface available", "VPN blocking UDP"], solutions: ["Check STUN/TURN server reachability", "Ensure UDP traffic is not blocked", "Use forceRelayCandidate option"] }, 33004: { name: "PEER_CONNECTION_FAILED", message: "Connection failed", description: "RTCPeerConnection entered the failed state. This is a recoverable condition — the SDK may attempt ICE restart or the connection may recover. If it does not recover, the call will eventually be terminated.", causes: ["ICE failure", "DTLS handshake failure", "Prolonged network interruption"], solutions: ["Wait for automatic recovery", "Check network connectivity", "Verify TURN server credentials"] }, 33005: { name: "ONLY_HOST_ICE_CANDIDATES", message: "Only local network candidates available", description: "ICE gathering completed but only host (local network) candidates were collected — no server-reflexive (srflx) or relay (turn) candidates were found. This typically means the STUN/TURN servers are unreachable, which will prevent connections outside the local network.", causes: ["STUN/TURN servers unreachable", "Firewall blocking UDP traffic to STUN/TURN servers", "Incorrect TURN server configuration or credentials", "Restrictive corporate network or VPN"], solutions: ["Verify STUN/TURN server URLs and credentials", "Ensure UDP traffic to STUN/TURN ports is not blocked", "Check firewall or VPN settings", "Try using TCP-based TURN as a fallback"] }, 34001: { name: "TOKEN_EXPIRING_SOON", message: "Authentication token expiring soon", description: "The authentication token is approaching its expiration time. If the token expires the connection will be lost and calls will fail. A new token should be generated before expiration.", causes: ["Token was issued with a limited lifetime"], solutions: ["Generate a new authentication token", "Reconnect with fresh credentials before the token expires"] }, 35001: { name: "SESSION_NOT_REATTACHED", message: "Active call lost after reconnect", description: "The WebSocket reconnected successfully but the server returned an empty reattached_sessions list while the SDK still has an active call. The server no longer knows about the call, so any subsequent call-control operation (hangup, hold, etc.) will fail with CALL_DOES_NOT_EXIST.", causes: ["Server-side session expired during the disconnection window", "Reconnect token was invalidated", "Backend restarted or lost in-memory call state"], solutions: ["Terminate the local call and notify the user", "Start a new call", "Investigate why the session was not preserved on the server"] } };
|
|
58
58
|
function ue(n, e) {
|
|
59
|
-
const t =
|
|
59
|
+
const t = Li[n];
|
|
60
60
|
return { code: n, name: t.name, message: t.message, description: t.description, causes: [...t.causes], solutions: [...t.solutions] };
|
|
61
61
|
}
|
|
62
62
|
class Ae extends Error {
|
|
@@ -69,22 +69,22 @@ class Ae extends Error {
|
|
|
69
69
|
}
|
|
70
70
|
function Oe(n) {
|
|
71
71
|
if (n instanceof DOMException) {
|
|
72
|
-
if (n.name === "NotAllowedError") return
|
|
73
|
-
if (n.name === "NotFoundError" || n.name === "OverconstrainedError") return
|
|
72
|
+
if (n.name === "NotAllowedError") return ti;
|
|
73
|
+
if (n.name === "NotFoundError" || n.name === "OverconstrainedError") return ni;
|
|
74
74
|
}
|
|
75
75
|
return ln;
|
|
76
76
|
}
|
|
77
77
|
function W(n, e, t) {
|
|
78
|
-
const i =
|
|
78
|
+
const i = Oi[n], s = e instanceof Error ? e : e !== void 0 ? new Error(String(e)) : void 0;
|
|
79
79
|
return new Ae({ code: n, name: i.name, description: i.description, message: t || i.message, causes: [...i.causes], solutions: [...i.solutions], originalError: s });
|
|
80
80
|
}
|
|
81
|
-
var
|
|
81
|
+
var Ni = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
82
82
|
function hn(n, e) {
|
|
83
83
|
return n(e = { exports: {} }, e.exports), e.exports;
|
|
84
84
|
}
|
|
85
|
-
var
|
|
85
|
+
var xi = hn((function(n) {
|
|
86
86
|
var e, t;
|
|
87
|
-
e =
|
|
87
|
+
e = Ni, t = function() {
|
|
88
88
|
var i = function() {
|
|
89
89
|
}, s = "undefined", o = typeof window !== s && typeof window.navigator !== s && /Trident\/|MSIE /.test(window.navigator.userAgent), r = ["trace", "debug", "info", "warn", "error"];
|
|
90
90
|
function c(m, w) {
|
|
@@ -192,7 +192,7 @@ var Ni = hn((function(n) {
|
|
|
192
192
|
}, n.exports ? n.exports = t() : e.log = t();
|
|
193
193
|
}));
|
|
194
194
|
const Rt = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
195
|
-
class
|
|
195
|
+
class Di {
|
|
196
196
|
constructor(e = {}) {
|
|
197
197
|
var t, i, s;
|
|
198
198
|
this.buffer = [], this.isCapturing = !1, this.options = { enabled: (t = e.enabled) !== null && t !== void 0 && t, level: (i = e.level) !== null && i !== void 0 ? i : "debug", maxEntries: (s = e.maxEntries) !== null && s !== void 0 ? s : 1e3 };
|
|
@@ -229,7 +229,7 @@ class xi {
|
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
let pn = null;
|
|
232
|
-
const g =
|
|
232
|
+
const g = xi.getLogger("telnyx"), We = { trace: 0, debug: 1, info: 2, warn: 3, error: 4 };
|
|
233
233
|
let fn = We.info;
|
|
234
234
|
function At(n) {
|
|
235
235
|
if (n == null || typeof n != "object") return n;
|
|
@@ -252,9 +252,9 @@ function At(n) {
|
|
|
252
252
|
}
|
|
253
253
|
return Object.keys(e).length > 0 ? e : { value: String(n) };
|
|
254
254
|
}
|
|
255
|
-
const
|
|
255
|
+
const Pi = g.methodFactory;
|
|
256
256
|
g.methodFactory = (n, e, t) => {
|
|
257
|
-
const i =
|
|
257
|
+
const i = Pi(n, e, t);
|
|
258
258
|
return function(...s) {
|
|
259
259
|
if (We[n] >= fn) {
|
|
260
260
|
const r = [(/* @__PURE__ */ new Date()).toISOString().replace("T", " ").replace("Z", ""), "-"];
|
|
@@ -285,7 +285,7 @@ const Ue = (n) => {
|
|
|
285
285
|
} catch {
|
|
286
286
|
return n;
|
|
287
287
|
}
|
|
288
|
-
}, Se = (n) => n instanceof Function || typeof n == "function", Ge = (n) => typeof document == "object" && "getElementById" in document ? typeof n == "string" ? document.getElementById(n) || null : typeof n == "function" ? n() : n instanceof HTMLMediaElement ? n : null : null,
|
|
288
|
+
}, Se = (n) => n instanceof Function || typeof n == "function", Ge = (n) => typeof document == "object" && "getElementById" in document ? typeof n == "string" ? document.getElementById(n) || null : typeof n == "function" ? n() : n instanceof HTMLMediaElement ? n : null : null, Mi = /^(ws|wss):\/\//, vn = (n, e = null) => {
|
|
289
289
|
const { result: t = {}, error: i } = n;
|
|
290
290
|
if (i) return { error: i };
|
|
291
291
|
const { result: s = null } = t;
|
|
@@ -300,10 +300,10 @@ const Ue = (n) => {
|
|
|
300
300
|
function Ot({ debounceTime: n }) {
|
|
301
301
|
let e, t;
|
|
302
302
|
return { promise: new Promise(((i, s) => {
|
|
303
|
-
e = n ?
|
|
303
|
+
e = n ? Ui(i, n) : i, t = s;
|
|
304
304
|
})), resolve: e, reject: t };
|
|
305
305
|
}
|
|
306
|
-
const
|
|
306
|
+
const Ui = (n, e) => {
|
|
307
307
|
let t;
|
|
308
308
|
return (...i) => {
|
|
309
309
|
clearTimeout(t), t = window.setTimeout((() => {
|
|
@@ -314,17 +314,20 @@ const Mi = (n, e) => {
|
|
|
314
314
|
function fe() {
|
|
315
315
|
return sessionStorage.getItem(St);
|
|
316
316
|
}
|
|
317
|
-
|
|
318
|
-
typeof window < "u" && window.addEventListener("beforeunload", (() => {
|
|
317
|
+
function _n() {
|
|
319
318
|
sessionStorage.removeItem(St);
|
|
319
|
+
}
|
|
320
|
+
var Q, ce, $;
|
|
321
|
+
typeof window < "u" && window.addEventListener("beforeunload", (() => {
|
|
322
|
+
_n();
|
|
320
323
|
})), (function(n) {
|
|
321
324
|
n.Offer = "offer", n.Answer = "answer";
|
|
322
|
-
})(
|
|
325
|
+
})(Q || (Q = {})), (function(n) {
|
|
323
326
|
n.Inbound = "inbound", n.Outbound = "outbound";
|
|
324
327
|
})(ce || (ce = {})), (function(n) {
|
|
325
328
|
n.Invite = "telnyx_rtc.invite", n.Attach = "telnyx_rtc.attach", n.Answer = "telnyx_rtc.answer", n.Info = "telnyx_rtc.info", n.Candidate = "telnyx_rtc.candidate", n.EndOfCandidates = "telnyx_rtc.endOfCandidates", n.Display = "telnyx_rtc.display", n.Media = "telnyx_rtc.media", n.Event = "telnyx_rtc.event", n.Bye = "telnyx_rtc.bye", n.Punt = "telnyx_rtc.punt", n.Broadcast = "telnyx_rtc.broadcast", n.Subscribe = "telnyx_rtc.subscribe", n.Unsubscribe = "telnyx_rtc.unsubscribe", n.ClientReady = "telnyx_rtc.clientReady", n.Modify = "telnyx_rtc.modify", n.Ringing = "telnyx_rtc.ringing", n.GatewayState = "telnyx_rtc.gatewayState", n.Ping = "telnyx_rtc.ping", n.Pong = "telnyx_rtc.pong";
|
|
326
329
|
})($ || ($ = {}));
|
|
327
|
-
const re = { generic: "event", [$.Display]: "participantData", [$.Attach]: "participantData", conferenceUpdate: "conferenceUpdate", callUpdate: "callUpdate", vertoClientReady: "vertoClientReady", userMediaError: "userMediaError", peerConnectionFailureError: "peerConnectionFailureError", signalingStateClosed: "signalingStateClosed" },
|
|
330
|
+
const re = { generic: "event", [$.Display]: "participantData", [$.Attach]: "participantData", conferenceUpdate: "conferenceUpdate", callUpdate: "callUpdate", vertoClientReady: "vertoClientReady", userMediaError: "userMediaError", peerConnectionFailureError: "peerConnectionFailureError", signalingStateClosed: "signalingStateClosed" }, Fi = { invalidCredentialsOptions: "InvalidCredentialsOptions" }, ji = { destinationNumber: "", remoteCallerName: "Outbound Call", remoteCallerNumber: "", callerName: "", callerNumber: "", audio: !0, useStereo: !1, debug: !1, debugOutput: "socket", attach: !1, screenShare: !1, userVariables: {}, mediaSettings: { useSdpASBandwidthKbps: !1, sdpASBandwidthKbps: 0 }, mutedMicOnStart: !1, prefetchIceCandidates: !0 };
|
|
328
331
|
var U, lt, oe, le, ne;
|
|
329
332
|
(function(n) {
|
|
330
333
|
n[n.New = 0] = "New", n[n.Requesting = 1] = "Requesting", n[n.Trying = 2] = "Trying", n[n.Recovering = 3] = "Recovering", n[n.Ringing = 4] = "Ringing", n[n.Answering = 5] = "Answering", n[n.Early = 6] = "Early", n[n.Active = 7] = "Active", n[n.Held = 8] = "Held", n[n.Hangup = 9] = "Hangup", n[n.Destroy = 10] = "Destroy", n[n.Purge = 11] = "Purge";
|
|
@@ -337,16 +340,16 @@ var U, lt, oe, le, ne;
|
|
|
337
340
|
})(le || (le = {})), (function(n) {
|
|
338
341
|
n.REGED = "REGED", n.UNREGED = "UNREGED", n.NOREG = "NOREG", n.FAILED = "FAILED", n.FAIL_WAIT = "FAIL_WAIT", n.REGISTER = "REGISTER", n.TRYING = "TRYING", n.EXPIRED = "EXPIRED", n.UNREGISTER = "UNREGISTER";
|
|
339
342
|
})(ne || (ne = {}));
|
|
340
|
-
const be = "GLOBAL", se = {}, De = (n, e) => `${n}|${e}`,
|
|
343
|
+
const be = "GLOBAL", se = {}, De = (n, e) => `${n}|${e}`, yn = (n, e = be) => De(n, e) in se, he = (n, e, t = be) => {
|
|
341
344
|
const i = De(n, t);
|
|
342
345
|
i in se || (se[i] = []), se[i].push(e);
|
|
343
|
-
},
|
|
346
|
+
}, Sn = (n, e, t = be) => {
|
|
344
347
|
const i = function(s) {
|
|
345
348
|
pe(n, i, t), e(s);
|
|
346
349
|
};
|
|
347
350
|
return i.prototype.targetRef = e, he(n, i, t);
|
|
348
351
|
}, pe = (n, e, t = be) => {
|
|
349
|
-
if (!
|
|
352
|
+
if (!yn(n, t)) return !1;
|
|
350
353
|
const i = De(n, t);
|
|
351
354
|
if (Se(e))
|
|
352
355
|
for (let s = se[i].length - 1; s >= 0; s--) {
|
|
@@ -357,7 +360,7 @@ const be = "GLOBAL", se = {}, De = (n, e) => `${n}|${e}`, _n = (n, e = be) => De
|
|
|
357
360
|
return se[i].length === 0 && delete se[i], !0;
|
|
358
361
|
}, L = (n, e, t = be, i = !0) => {
|
|
359
362
|
const s = i && t !== be;
|
|
360
|
-
if (!
|
|
363
|
+
if (!yn(n, t)) return s && L(n, e), !1;
|
|
361
364
|
const o = De(n, t), r = se[o].length;
|
|
362
365
|
if (!r) return s && L(n, e), !1;
|
|
363
366
|
for (let c = r - 1; c >= 0; c--) se[o][c](e);
|
|
@@ -366,22 +369,22 @@ const be = "GLOBAL", se = {}, De = (n, e) => `${n}|${e}`, _n = (n, e = be) => De
|
|
|
366
369
|
const e = De(n, "");
|
|
367
370
|
Object.keys(se).filter(((t) => t.indexOf(e) === 0)).forEach(((t) => delete se[t]));
|
|
368
371
|
};
|
|
369
|
-
let
|
|
370
|
-
const
|
|
372
|
+
let Bi = typeof WebSocket < "u" ? WebSocket : null;
|
|
373
|
+
const $i = 0, Hi = 1, Wi = 2, Lt = 3;
|
|
371
374
|
class Nt {
|
|
372
375
|
constructor(e) {
|
|
373
376
|
this.session = e, this.previousGatewayState = "", this._wsClient = null, this._host = kt, this._timers = {}, this._useCanaryRtcServer = !1, this._hasCanaryBeenUsed = !1, this._safetyTimeoutId = null, this.upDur = null, this.downDur = null;
|
|
374
377
|
const { host: t, env: i, region: s, useCanaryRtcServer: o } = e.options;
|
|
375
|
-
i && (this._host = i === "development" ? "wss://rtcdev.telnyx.com" : kt), t && (this._host = ((r) => `${
|
|
378
|
+
i && (this._host = i === "development" ? "wss://rtcdev.telnyx.com" : kt), t && (this._host = ((r) => `${Mi.test(r) ? "" : "wss://"}${r}`)(t)), s && (this._host = this._host.replace(/rtc(dev)?/, `${s}.rtc$1`)), o && (this._useCanaryRtcServer = !0);
|
|
376
379
|
}
|
|
377
380
|
get connected() {
|
|
378
|
-
return !!this._wsClient && this._wsClient.readyState ===
|
|
381
|
+
return !!this._wsClient && this._wsClient.readyState === Hi;
|
|
379
382
|
}
|
|
380
383
|
get connecting() {
|
|
381
|
-
return !!this._wsClient && this._wsClient.readyState ===
|
|
384
|
+
return !!this._wsClient && this._wsClient.readyState === $i;
|
|
382
385
|
}
|
|
383
386
|
get closing() {
|
|
384
|
-
return !!this._wsClient && this._wsClient.readyState ===
|
|
387
|
+
return !!this._wsClient && this._wsClient.readyState === Wi;
|
|
385
388
|
}
|
|
386
389
|
get closed() {
|
|
387
390
|
return !!this._wsClient && this._wsClient.readyState === Lt;
|
|
@@ -400,10 +403,10 @@ class Nt {
|
|
|
400
403
|
let t = fe();
|
|
401
404
|
this.session.options.rtcIp && this.session.options.rtcPort && (t = null, this._useCanaryRtcServer = !1, e.searchParams.set("rtc_ip", this.session.options.rtcIp), e.searchParams.set("rtc_port", this.session.options.rtcPort.toString())), t && e.searchParams.set("voice_sdk_id", t), this._useCanaryRtcServer && (e.searchParams.set("canary", "true"), t && !this._hasCanaryBeenUsed && (e.searchParams.delete("voice_sdk_id"), g.debug("first canary connection. Refreshing voice_sdk_id")), this._hasCanaryBeenUsed = !0);
|
|
402
405
|
try {
|
|
403
|
-
this._wsClient = new
|
|
406
|
+
this._wsClient = new Bi(e.toString()), this._registerSocketEvents(this._wsClient);
|
|
404
407
|
} catch (i) {
|
|
405
408
|
g.error("WebSocket connection failed:", i);
|
|
406
|
-
const s = W(
|
|
409
|
+
const s = W(ai, i);
|
|
407
410
|
L(T.Error, { error: s, sessionId: this.session.sessionid }, this.session.uuid);
|
|
408
411
|
}
|
|
409
412
|
}
|
|
@@ -415,7 +418,7 @@ class Nt {
|
|
|
415
418
|
var t;
|
|
416
419
|
const { request: i } = e, s = new Promise(((o, r) => {
|
|
417
420
|
if (i.hasOwnProperty("result")) return o();
|
|
418
|
-
|
|
421
|
+
Sn(i.id, ((c) => {
|
|
419
422
|
const { result: u, error: l } = vn(c);
|
|
420
423
|
return l ? r(l) : o(u);
|
|
421
424
|
}));
|
|
@@ -432,7 +435,7 @@ class Nt {
|
|
|
432
435
|
_registerSocketEvents(e) {
|
|
433
436
|
e.onopen = (t) => L(T.SocketOpen, t, this.session.uuid), e.onclose = (t) => (this._clearSafetyTimeout(), this._safetyCleanupSocket(e, "close"), L(T.SocketClose, t, this.session.uuid)), e.onerror = (t) => {
|
|
434
437
|
this._clearSafetyTimeout(), this._safetyCleanupSocket(e, "error");
|
|
435
|
-
const i = W(
|
|
438
|
+
const i = W(ci);
|
|
436
439
|
return L(T.Error, { error: i, sessionId: this.session.sessionid }, this.session.uuid), L(T.SocketError, { error: t, sessionId: this.session.sessionid }, this.session.uuid);
|
|
437
440
|
}, e.onmessage = (t) => {
|
|
438
441
|
var i, s;
|
|
@@ -452,7 +455,7 @@ class Nt {
|
|
|
452
455
|
e.onopen = null, e.onclose = null, e.onerror = null, e.onmessage = null;
|
|
453
456
|
}
|
|
454
457
|
_handleCloseTimeout(e) {
|
|
455
|
-
this._safetyTimeoutId = null, e && e.readyState !== Lt ? (g.warn("Socket stuck in CLOSING after 5s — forcefully cleaning up"), this._deregisterSocketEvents(e), this._safetyCleanupSocket(e, "timeout"), this._wsClient && this._wsClient !== e || L(T.SocketClose, { code:
|
|
458
|
+
this._safetyTimeoutId = null, e && e.readyState !== Lt ? (g.warn("Socket stuck in CLOSING after 5s — forcefully cleaning up"), this._deregisterSocketEvents(e), this._safetyCleanupSocket(e, "timeout"), this._wsClient && this._wsClient !== e || L(T.SocketClose, { code: ki, reason: "STUCK_WS_TIMEOUT: Socket got stuck in CLOSING state and was forcefully cleaned up by safety timeout", wasClean: !1 }, this.session.uuid)) : g.warn("Safety timeout fired but socket is already closed or cleaned up");
|
|
456
459
|
}
|
|
457
460
|
_clearSafetyTimeout() {
|
|
458
461
|
this._safetyTimeoutId && (g.debug("Clearing safety timeout"), clearTimeout(this._safetyTimeoutId), this._safetyTimeoutId = null);
|
|
@@ -490,37 +493,37 @@ class ee extends Pe {
|
|
|
490
493
|
this.buildRequest({ method: this.toString(), params: e });
|
|
491
494
|
}
|
|
492
495
|
}
|
|
493
|
-
class
|
|
496
|
+
class bn extends ee {
|
|
494
497
|
constructor(e) {
|
|
495
498
|
super(), this.method = $.GatewayState, this.buildRequest({ method: this.method, voice_sdk_id: e, params: {} });
|
|
496
499
|
}
|
|
497
500
|
}
|
|
498
|
-
class
|
|
501
|
+
class Gi {
|
|
499
502
|
constructor(e) {
|
|
500
503
|
this.pendingRequestId = null, this.onSocketMessage = (t) => O(this, void 0, void 0, (function* () {
|
|
501
504
|
t.id === this.pendingRequestId && this.gatewayStateTask.resolve(yt(t));
|
|
502
505
|
})), this.getIsRegistered = () => O(this, void 0, void 0, (function* () {
|
|
503
|
-
const t = new
|
|
506
|
+
const t = new bn(fe());
|
|
504
507
|
this.pendingRequestId = t.request.id, this.gatewayStateTask = Ot({}), this.session.execute(t);
|
|
505
508
|
const i = yield this.gatewayStateTask.promise;
|
|
506
509
|
return !!i && [ne.REGISTER, ne.REGED].includes(i);
|
|
507
510
|
})), this.session = e, this.gatewayStateTask = Ot({}), this.session.on("telnyx.socket.message", this.onSocketMessage);
|
|
508
511
|
}
|
|
509
512
|
}
|
|
510
|
-
class
|
|
513
|
+
class Cn extends ee {
|
|
511
514
|
constructor(e) {
|
|
512
515
|
super(), this.method = $.Ping, this.buildRequest({ method: this.method, voice_sdk_id: e, params: {} });
|
|
513
516
|
}
|
|
514
517
|
}
|
|
515
|
-
var
|
|
516
|
-
class
|
|
518
|
+
var wn = "2.26.3", bt = wn;
|
|
519
|
+
class Vi extends ee {
|
|
517
520
|
constructor(e, t, i, s, o = {}, r) {
|
|
518
521
|
super(), this.method = "login";
|
|
519
522
|
const c = { login: e, passwd: t, login_token: i, userVariables: o, reconnection: r, loginParams: {}, "User-Agent": { sdkVersion: bt, data: navigator.userAgent } };
|
|
520
523
|
s && (c.sessid = s), this.buildRequest({ method: this.method, params: c });
|
|
521
524
|
}
|
|
522
525
|
}
|
|
523
|
-
class
|
|
526
|
+
class qi extends ee {
|
|
524
527
|
constructor(e, t) {
|
|
525
528
|
super(), this.buildRequest({ id: e, result: { method: t } });
|
|
526
529
|
}
|
|
@@ -540,12 +543,12 @@ class Mt extends ee {
|
|
|
540
543
|
return $.Attach;
|
|
541
544
|
}
|
|
542
545
|
}
|
|
543
|
-
class
|
|
546
|
+
class Yi extends ee {
|
|
544
547
|
toString() {
|
|
545
548
|
return $.Bye;
|
|
546
549
|
}
|
|
547
550
|
}
|
|
548
|
-
class
|
|
551
|
+
class Ji extends ee {
|
|
549
552
|
toString() {
|
|
550
553
|
return $.Candidate;
|
|
551
554
|
}
|
|
@@ -565,12 +568,12 @@ class Ut extends ee {
|
|
|
565
568
|
return $.Info;
|
|
566
569
|
}
|
|
567
570
|
}
|
|
568
|
-
class
|
|
571
|
+
class zi extends ee {
|
|
569
572
|
toString() {
|
|
570
573
|
return $.Broadcast;
|
|
571
574
|
}
|
|
572
575
|
}
|
|
573
|
-
class
|
|
576
|
+
class Qi extends ee {
|
|
574
577
|
toString() {
|
|
575
578
|
return $.Subscribe;
|
|
576
579
|
}
|
|
@@ -580,7 +583,7 @@ class Xi extends ee {
|
|
|
580
583
|
return $.Unsubscribe;
|
|
581
584
|
}
|
|
582
585
|
}
|
|
583
|
-
class
|
|
586
|
+
class Zi extends ee {
|
|
584
587
|
constructor(e) {
|
|
585
588
|
super(), this.method = "anonymous_login";
|
|
586
589
|
const { target_type: t, target_id: i, target_version_id: s, target_params: o, userVariables: r, sessionId: c, reconnection: u } = e, l = { target_type: t, target_id: i, userVariables: r, reconnection: u, "User-Agent": { sdkVersion: bt, data: navigator.userAgent } };
|
|
@@ -591,7 +594,7 @@ class Le {
|
|
|
591
594
|
constructor(e) {
|
|
592
595
|
if (this.options = e, this.uuid = ye(), this.sessionid = "", this.subscriptions = {}, this.signature = null, this.relayProtocol = null, this.contexts = [], this.timeoutErrorCode = -32e3, this.invalidMethodErrorCode = -32601, this.authenticationRequiredErrorCode = -32e3, this.callReportId = null, this.dc = null, this.region = null, this.connection = null, this._jwtAuth = !1, this._autoReconnect = !0, this._idle = !1, this._tokenExpiryTimeout = null, this._executeQueue = [], !this.validateOptions()) throw new Error("Invalid init options");
|
|
593
596
|
var t, i;
|
|
594
|
-
t = e.debug ? "debug" : "info", fn = (i = We[t]) !== null && i !== void 0 ? i : We.info, this._onSocketOpen = this._onSocketOpen.bind(this), this.onNetworkClose = this.onNetworkClose.bind(this), this._onSocketMessage = this._onSocketMessage.bind(this), this._handleLoginError = this._handleLoginError.bind(this), this._attachListeners(), this.connection = new Nt(this), this.registerAgent = new
|
|
597
|
+
t = e.debug ? "debug" : "info", fn = (i = We[t]) !== null && i !== void 0 ? i : We.info, this._onSocketOpen = this._onSocketOpen.bind(this), this.onNetworkClose = this.onNetworkClose.bind(this), this._onSocketMessage = this._onSocketMessage.bind(this), this._handleLoginError = this._handleLoginError.bind(this), this._attachListeners(), this.connection = new Nt(this), this.registerAgent = new Gi(this);
|
|
595
598
|
}
|
|
596
599
|
get __logger() {
|
|
597
600
|
return g;
|
|
@@ -611,7 +614,7 @@ class Le {
|
|
|
611
614
|
return this._idle ? new Promise(((t) => this._executeQueue.push({ resolve: t, msg: e }))) : this.connected ? this.connection.send(e).catch(((t) => O(this, void 0, void 0, (function* () {
|
|
612
615
|
if (t?.code === this.authenticationRequiredErrorCode) {
|
|
613
616
|
if (!this._autoReconnect) {
|
|
614
|
-
const i = W(
|
|
617
|
+
const i = W(hi, t);
|
|
615
618
|
L(T.Error, { error: i, sessionId: this.sessionid }, this.uuid);
|
|
616
619
|
}
|
|
617
620
|
yield this.login();
|
|
@@ -649,6 +652,9 @@ class Le {
|
|
|
649
652
|
const t = W(dn, e);
|
|
650
653
|
L(T.Error, { error: t, sessionId: this.sessionid }, this.uuid);
|
|
651
654
|
}
|
|
655
|
+
clearReconnectToken() {
|
|
656
|
+
_n();
|
|
657
|
+
}
|
|
652
658
|
_checkTokenExpiry() {
|
|
653
659
|
this._clearTokenExpiryTimeout();
|
|
654
660
|
const e = this.options.login_token;
|
|
@@ -671,7 +677,7 @@ class Le {
|
|
|
671
677
|
}
|
|
672
678
|
}
|
|
673
679
|
_emitTokenExpiryWarning() {
|
|
674
|
-
const e = ue(
|
|
680
|
+
const e = ue(Ei);
|
|
675
681
|
L(T.Warning, { warning: e, sessionId: this.sessionid }, this.uuid);
|
|
676
682
|
}
|
|
677
683
|
_clearTokenExpiryTimeout() {
|
|
@@ -685,8 +691,8 @@ class Le {
|
|
|
685
691
|
{
|
|
686
692
|
const s = "Invalid login options provided for authentication.";
|
|
687
693
|
g.error(s);
|
|
688
|
-
const o = W(
|
|
689
|
-
return void L(T.Error, { error: o, type:
|
|
694
|
+
const o = W(ui, void 0, s);
|
|
695
|
+
return void L(T.Error, { error: o, type: Fi.invalidCredentialsOptions, sessionId: this.sessionid }, this.uuid);
|
|
690
696
|
}
|
|
691
697
|
}
|
|
692
698
|
}));
|
|
@@ -694,7 +700,7 @@ class Le {
|
|
|
694
700
|
_login({ type: e, onSuccess: t, onError: i }) {
|
|
695
701
|
return O(this, void 0, void 0, (function* () {
|
|
696
702
|
let s;
|
|
697
|
-
s = e === "login" ? new
|
|
703
|
+
s = e === "login" ? new Vi(this.options.login, this.options.password || this.options.passwd, this.options.login_token, this.sessionid, this.options.userVariables, !!fe()) : new Zi({ target_id: this.options.anonymous_login.target_id, target_type: this.options.anonymous_login.target_type, target_version_id: this.options.anonymous_login.target_version_id, target_params: this.options.anonymous_login.target_params, sessionId: this.sessionid, userVariables: this.options.userVariables, reconnection: !!fe() });
|
|
698
704
|
const o = yield this.execute(s).catch(((r) => {
|
|
699
705
|
this._handleLoginError(r), i && i(r);
|
|
700
706
|
}));
|
|
@@ -738,7 +744,7 @@ class Le {
|
|
|
738
744
|
this._idle = !0, clearTimeout(this._keepAliveTimeout), this.connection && this.connection.close();
|
|
739
745
|
}
|
|
740
746
|
_resetKeepAlive() {
|
|
741
|
-
this._pong === !1 && (g.warn("No ping/pong received, forcing PING ACK to keep alive"), this.execute(new
|
|
747
|
+
this._pong === !1 && (g.warn("No ping/pong received, forcing PING ACK to keep alive"), this.execute(new Cn(fe()))), clearTimeout(this._keepAliveTimeout), this._triggerKeepAliveTimeoutCheck();
|
|
742
748
|
}
|
|
743
749
|
_triggerKeepAliveTimeoutCheck() {
|
|
744
750
|
this._pong = !1, this._keepAliveTimeout = setTimeout((() => this._resetKeepAlive()), 35e3);
|
|
@@ -766,7 +772,7 @@ Le.TOKEN_EXPIRY_WARNING_SECONDS = 120;
|
|
|
766
772
|
const qe = (n) => navigator.mediaDevices.getUserMedia(n), me = (n) => n && n instanceof MediaStream, Re = (n, e) => {
|
|
767
773
|
const t = Ge(n);
|
|
768
774
|
t !== null && (t.getAttribute("autoplay") || t.setAttribute("autoplay", "autoplay"), t.getAttribute("playsinline") || t.setAttribute("playsinline", "playsinline"), t.srcObject = e);
|
|
769
|
-
},
|
|
775
|
+
}, En = (n, e) => O(void 0, void 0, void 0, (function* () {
|
|
770
776
|
const t = Ge(n);
|
|
771
777
|
if (t === null) return g.info("No HTMLMediaElement to attach the speakerId"), !1;
|
|
772
778
|
if (typeof e != "string") return g.info(`Invalid speaker deviceId: '${e}'`), !1;
|
|
@@ -775,10 +781,10 @@ const qe = (n) => navigator.mediaDevices.getUserMedia(n), me = (n) => n && n ins
|
|
|
775
781
|
} catch {
|
|
776
782
|
return !1;
|
|
777
783
|
}
|
|
778
|
-
})),
|
|
784
|
+
})), es = (n) => {
|
|
779
785
|
n && n.readyState === "live" && n.stop();
|
|
780
786
|
}, Ne = (n) => {
|
|
781
|
-
me(n) && n.getTracks().forEach(
|
|
787
|
+
me(n) && n.getTracks().forEach(es), n = null;
|
|
782
788
|
}, Ye = (n) => O(void 0, void 0, void 0, (function* () {
|
|
783
789
|
g.info("RTCService.getUserMedia", n);
|
|
784
790
|
const { audio: e, video: t } = n;
|
|
@@ -826,14 +832,14 @@ const qe = (n) => navigator.mediaDevices.getUserMedia(n), me = (n) => n && n ins
|
|
|
826
832
|
}));
|
|
827
833
|
}
|
|
828
834
|
return t;
|
|
829
|
-
})), Ft = [[320, 240], [640, 360], [640, 480], [1280, 720], [1920, 1080]],
|
|
835
|
+
})), Ft = [[320, 240], [640, 360], [640, 480], [1280, 720], [1920, 1080]], Je = (n, e, t) => O(void 0, void 0, void 0, (function* () {
|
|
830
836
|
const i = yield Te(t, !0);
|
|
831
837
|
for (let s = 0; s < i.length; s++) {
|
|
832
838
|
const { deviceId: o, label: r } = i[s];
|
|
833
839
|
if (n === o || e === r) return o;
|
|
834
840
|
}
|
|
835
841
|
return null;
|
|
836
|
-
})),
|
|
842
|
+
})), ts = (n) => {
|
|
837
843
|
const e = navigator.mediaDevices.getSupportedConstraints();
|
|
838
844
|
Object.keys(n).map(((t) => {
|
|
839
845
|
e.hasOwnProperty(t) && n[t] !== null && n[t] !== void 0 || delete n[t];
|
|
@@ -880,7 +886,7 @@ const qe = (n) => navigator.mediaDevices.getUserMedia(n), me = (n) => n && n ins
|
|
|
880
886
|
_e(n, "audio", !1);
|
|
881
887
|
}, Bt = (n) => {
|
|
882
888
|
_e(n, "audio", null);
|
|
883
|
-
},
|
|
889
|
+
}, ns = (n) => ((e, t = null) => {
|
|
884
890
|
if (!me(e)) return null;
|
|
885
891
|
let i = [];
|
|
886
892
|
switch (t) {
|
|
@@ -895,7 +901,7 @@ const qe = (n) => navigator.mediaDevices.getUserMedia(n), me = (n) => n && n ins
|
|
|
895
901
|
}
|
|
896
902
|
return i.some(((s) => s.enabled));
|
|
897
903
|
})(n, "audio");
|
|
898
|
-
function
|
|
904
|
+
function is() {
|
|
899
905
|
try {
|
|
900
906
|
const { browserInfo: n, name: e, version: t, supportAudio: i, supportVideo: s } = (function() {
|
|
901
907
|
if (!window || !window.navigator || !window.navigator.userAgent) throw new Error("You should use @telnyx/webrtc in a web browser such as Chrome|Firefox|Safari");
|
|
@@ -956,16 +962,16 @@ const Gt = (n) => {
|
|
|
956
962
|
s.startsWith("audio/") ? e.push(i) : s.startsWith("video/") && t.push(i);
|
|
957
963
|
})), { audioCodecs: e, videoCodecs: t }) : { audioCodecs: e, videoCodecs: t };
|
|
958
964
|
};
|
|
959
|
-
class
|
|
965
|
+
class ss extends Pe {
|
|
960
966
|
constructor(e, t) {
|
|
961
967
|
super(), this.method = "ai_conversation", this.buildRequest({ method: this.method, params: { type: "conversation.item.create", previous_item_id: null, item: { id: ye(), type: "message", role: "user", content: [{ type: "input_text", text: e }, ...t?.map(((i) => ({ type: "image_url", image_url: { url: i } })))] } } });
|
|
962
968
|
}
|
|
963
969
|
}
|
|
964
|
-
class
|
|
970
|
+
class J {
|
|
965
971
|
constructor(e, t) {
|
|
966
972
|
var i;
|
|
967
973
|
this.peerConnection = null, this.intervalId = null, this.statsBuffer = [], this.intervalStartTime = null, this.callEndTime = null, this.logCollector = null, this.intervalAudioLevels = { outbound: [], inbound: [] }, this.intervalJitters = [], this.intervalRTTs = [], this.intervalBitrates = { outbound: [], inbound: [] }, this.previousStats = {}, this.previousCandidatePairId = null, this.MAX_BUFFER_SIZE = 360, this.onFlushNeeded = null, this.onWarning = null, this._breachCounters = {}, this._activeWarnings = /* @__PURE__ */ new Set(), this._lastWarningEmitted = {}, this._prevPacketsReceived = null, this._prevPacketsLost = null, this._segmentIndex = 0, this._flushing = !1, this.options = e, this.logCollectorOptions = t || { enabled: !1, level: "debug", maxEntries: 1e3 }, this.callStartTime = /* @__PURE__ */ new Date(), this.logCollectorOptions.enabled && (this.logCollector = (function(s) {
|
|
968
|
-
return new
|
|
974
|
+
return new Di(s);
|
|
969
975
|
})(this.logCollectorOptions), this.logCollector.start(), i = this.logCollector, pn = i);
|
|
970
976
|
}
|
|
971
977
|
start(e) {
|
|
@@ -1025,7 +1031,7 @@ class K {
|
|
|
1025
1031
|
g.error(`CallReportCollector: Failed to post ${l}`, { status: y.status, error: v });
|
|
1026
1032
|
}
|
|
1027
1033
|
} catch (c) {
|
|
1028
|
-
g.warn(`CallReportCollector: Network error posting call report, retrying in ${
|
|
1034
|
+
g.warn(`CallReportCollector: Network error posting call report, retrying in ${J.RETRY_DELAY_MS}ms`, { error: c }), yield new Promise(((u) => setTimeout(u, J.RETRY_DELAY_MS)));
|
|
1029
1035
|
try {
|
|
1030
1036
|
const u = new URL(i), l = `${u.protocol.replace(/^ws/, "http")}//${u.host}/call_report`, f = { "Content-Type": "application/json", "x-call-report-id": t, "x-call-id": e.summary.callId };
|
|
1031
1037
|
s && (f["x-voice-sdk-id"] = s);
|
|
@@ -1099,7 +1105,7 @@ class K {
|
|
|
1099
1105
|
const v = this._createStatsEntry(this.intervalStartTime, r, l, f, h, c, u, S);
|
|
1100
1106
|
if (this.statsBuffer.push(v), this.statsBuffer.length > this.MAX_BUFFER_SIZE && (this.statsBuffer.shift(), g.warn("CallReportCollector: Buffer size limit reached, removing oldest entry")), this.onFlushNeeded && !this._flushing) {
|
|
1101
1107
|
const E = this.statsBuffer.length, m = (s = (i = this.logCollector) === null || i === void 0 ? void 0 : i.getLogCount()) !== null && s !== void 0 ? s : 0;
|
|
1102
|
-
if (E >=
|
|
1108
|
+
if (E >= J.STATS_FLUSH_THRESHOLD || m >= J.LOGS_FLUSH_THRESHOLD) {
|
|
1103
1109
|
g.info("CallReportCollector: Approaching buffer limits, requesting flush", { statsIntervals: E, logEntries: m });
|
|
1104
1110
|
try {
|
|
1105
1111
|
this.onFlushNeeded();
|
|
@@ -1128,26 +1134,26 @@ class K {
|
|
|
1128
1134
|
}
|
|
1129
1135
|
this._prevPacketsReceived = F, this._prevPacketsLost = R;
|
|
1130
1136
|
}
|
|
1131
|
-
if (this._trackBreach(
|
|
1137
|
+
if (this._trackBreach(fi, P !== void 0 && P > J.THRESHOLD_RTT_MS), this._trackBreach(gi, M !== void 0 && M > J.THRESHOLD_JITTER_MS), this._trackBreach(vi, q !== void 0 && q > J.THRESHOLD_PACKET_LOSS_PCT), P !== void 0 && M !== void 0 && q !== void 0) {
|
|
1132
1138
|
const F = 93.2 - 0.11 * M - 2.5 * q - 0.01 * (1e3 * P), R = Math.max(1, Math.min(4.5, 1 + 0.035 * F + F * (F - 60) * (100 - F) * 7e-6));
|
|
1133
|
-
this._trackBreach(Tt, R <
|
|
1139
|
+
this._trackBreach(Tt, R < J.THRESHOLD_MOS);
|
|
1134
1140
|
} else this._trackBreach(Tt, !1);
|
|
1135
1141
|
if (((l = (u = e.audio) === null || u === void 0 ? void 0 : u.inbound) === null || l === void 0 ? void 0 : l.bytesReceived) !== void 0 && this.statsBuffer.length > 1) {
|
|
1136
1142
|
const F = this.statsBuffer[this.statsBuffer.length - 2], R = (S = (h = (f = F?.audio) === null || f === void 0 ? void 0 : f.inbound) === null || h === void 0 ? void 0 : h.bytesReceived) !== null && S !== void 0 ? S : 0, a = (y = e.audio.inbound.bytesReceived) !== null && y !== void 0 ? y : 0;
|
|
1137
|
-
this._trackBreach(
|
|
1143
|
+
this._trackBreach(mi, a - R == 0);
|
|
1138
1144
|
}
|
|
1139
1145
|
if (((E = (v = e.audio) === null || v === void 0 ? void 0 : v.outbound) === null || E === void 0 ? void 0 : E.bytesSent) !== void 0 && this.statsBuffer.length > 1) {
|
|
1140
1146
|
const F = this.statsBuffer[this.statsBuffer.length - 2], R = (N = (w = (m = F?.audio) === null || m === void 0 ? void 0 : m.outbound) === null || w === void 0 ? void 0 : w.bytesSent) !== null && N !== void 0 ? N : 0, a = (A = e.audio.outbound.bytesSent) !== null && A !== void 0 ? A : 0;
|
|
1141
|
-
this._trackBreach(
|
|
1147
|
+
this._trackBreach(_i, a - R == 0);
|
|
1142
1148
|
}
|
|
1143
1149
|
}
|
|
1144
1150
|
_trackBreach(e, t) {
|
|
1145
1151
|
var i, s, o;
|
|
1146
1152
|
if (t) {
|
|
1147
|
-
if (this._breachCounters[e] = ((i = this._breachCounters[e]) !== null && i !== void 0 ? i : 0) + 1, this._breachCounters[e] >=
|
|
1153
|
+
if (this._breachCounters[e] = ((i = this._breachCounters[e]) !== null && i !== void 0 ? i : 0) + 1, this._breachCounters[e] >= J.CONSECUTIVE_BREACHES_REQUIRED) {
|
|
1148
1154
|
this._activeWarnings.add(e);
|
|
1149
1155
|
const r = Date.now();
|
|
1150
|
-
if (r - ((s = this._lastWarningEmitted[e]) !== null && s !== void 0 ? s : 0) >=
|
|
1156
|
+
if (r - ((s = this._lastWarningEmitted[e]) !== null && s !== void 0 ? s : 0) >= J.WARNING_THROTTLE_MS) {
|
|
1151
1157
|
this._lastWarningEmitted[e] = r;
|
|
1152
1158
|
try {
|
|
1153
1159
|
const c = ue(e);
|
|
@@ -1211,8 +1217,8 @@ class K {
|
|
|
1211
1217
|
this.intervalAudioLevels = { outbound: [], inbound: [] }, this.intervalJitters = [], this.intervalRTTs = [], this.intervalBitrates = { outbound: [], inbound: [] };
|
|
1212
1218
|
}
|
|
1213
1219
|
}
|
|
1214
|
-
|
|
1215
|
-
var Fe,
|
|
1220
|
+
J.STATS_FLUSH_THRESHOLD = 300, J.LOGS_FLUSH_THRESHOLD = 800, J.CONSECUTIVE_BREACHES_REQUIRED = 3, J.THRESHOLD_RTT_MS = 0.4, J.THRESHOLD_JITTER_MS = 30, J.THRESHOLD_PACKET_LOSS_PCT = 1, J.THRESHOLD_MOS = 3.5, J.WARNING_THROTTLE_MS = 15e3, J.RETRY_DELAY_MS = 500;
|
|
1221
|
+
var Fe, In = hn((function(n, e) {
|
|
1216
1222
|
var t;
|
|
1217
1223
|
function i() {
|
|
1218
1224
|
}
|
|
@@ -1281,32 +1287,32 @@ var Fe, En = hn((function(n, e) {
|
|
|
1281
1287
|
case 1:
|
|
1282
1288
|
(function(G, C, D) {
|
|
1283
1289
|
if (C) G.call(D);
|
|
1284
|
-
else for (var j = G.length, H = l(G, j),
|
|
1290
|
+
else for (var j = G.length, H = l(G, j), K = 0; K < j; ++K) H[K].call(D);
|
|
1285
1291
|
})(p, ie, this);
|
|
1286
1292
|
break;
|
|
1287
1293
|
case 2:
|
|
1288
1294
|
(function(G, C, D, j) {
|
|
1289
1295
|
if (C) G.call(D, j);
|
|
1290
|
-
else for (var H = G.length,
|
|
1296
|
+
else for (var H = G.length, K = l(G, H), X = 0; X < H; ++X) K[X].call(D, j);
|
|
1291
1297
|
})(p, ie, this, arguments[1]);
|
|
1292
1298
|
break;
|
|
1293
1299
|
case 3:
|
|
1294
1300
|
(function(G, C, D, j, H) {
|
|
1295
1301
|
if (C) G.call(D, j, H);
|
|
1296
|
-
else for (var
|
|
1302
|
+
else for (var K = G.length, X = l(G, K), V = 0; V < K; ++V) X[V].call(D, j, H);
|
|
1297
1303
|
})(p, ie, this, arguments[1], arguments[2]);
|
|
1298
1304
|
break;
|
|
1299
1305
|
case 4:
|
|
1300
|
-
(function(G, C, D, j, H,
|
|
1301
|
-
if (C) G.call(D, j, H,
|
|
1302
|
-
else for (var
|
|
1306
|
+
(function(G, C, D, j, H, K) {
|
|
1307
|
+
if (C) G.call(D, j, H, K);
|
|
1308
|
+
else for (var X = G.length, V = l(G, X), ae = 0; ae < X; ++ae) V[ae].call(D, j, H, K);
|
|
1303
1309
|
})(p, ie, this, arguments[1], arguments[2], arguments[3]);
|
|
1304
1310
|
break;
|
|
1305
1311
|
default:
|
|
1306
1312
|
for (b = Array(_ - 1), k = 1; k < _; k++) b[k - 1] = arguments[k];
|
|
1307
1313
|
(function(G, C, D, j) {
|
|
1308
1314
|
if (C) G.apply(D, j);
|
|
1309
|
-
else for (var H = G.length,
|
|
1315
|
+
else for (var H = G.length, K = l(G, H), X = 0; X < H; ++X) K[X].apply(D, j);
|
|
1310
1316
|
})(p, ie, this, b);
|
|
1311
1317
|
}
|
|
1312
1318
|
return !0;
|
|
@@ -1786,9 +1792,9 @@ var Fe, En = hn((function(n, e) {
|
|
|
1786
1792
|
}
|
|
1787
1793
|
};
|
|
1788
1794
|
}));
|
|
1789
|
-
(Fe =
|
|
1790
|
-
var
|
|
1791
|
-
function
|
|
1795
|
+
(Fe = In) && Fe.__esModule && Object.prototype.hasOwnProperty.call(Fe, "default") && Fe.default;
|
|
1796
|
+
var os = In.WebRTCStats;
|
|
1797
|
+
function rs(n) {
|
|
1792
1798
|
const { packetsLost: e, packetsReceived: t, jitter: i, rtt: s } = n, o = (function(l) {
|
|
1793
1799
|
const { jitter: f, rtt: h } = l, S = f + h / 2;
|
|
1794
1800
|
return 0.024 * S + 0.11 * (S - 177.3) * (S > 177.3 ? 1 : 0);
|
|
@@ -1798,20 +1804,20 @@ function os(n) {
|
|
|
1798
1804
|
})({ packetsLost: e, packetsReceived: t }), c = 93.2 - o - r + 0, u = 1 + 0.035 * c + 7e-6 * c * (c - 60) * (100 - c);
|
|
1799
1805
|
return Math.min(Math.max(u, 1), 5);
|
|
1800
1806
|
}
|
|
1801
|
-
function
|
|
1807
|
+
function as(n) {
|
|
1802
1808
|
return isNaN(n) ? null : n > 4.2 ? "excellent" : n >= 4.1 && n <= 4.2 ? "good" : n >= 3.7 && n <= 4 ? "fair" : n >= 3.1 && n <= 3.6 ? "poor" : "bad";
|
|
1803
1809
|
}
|
|
1804
|
-
class
|
|
1810
|
+
class cs extends Pe {
|
|
1805
1811
|
constructor(e, t) {
|
|
1806
1812
|
super(), this.buildRequest({ type: "debug_report_start", debug_report_id: e, debug_report_version: 1, call_id: t });
|
|
1807
1813
|
}
|
|
1808
1814
|
}
|
|
1809
|
-
class
|
|
1815
|
+
class ls extends Pe {
|
|
1810
1816
|
constructor(e, t) {
|
|
1811
1817
|
super(), this.buildRequest({ type: "debug_report_stop", debug_report_id: e, debug_report_version: 1, call_id: t });
|
|
1812
1818
|
}
|
|
1813
1819
|
}
|
|
1814
|
-
class
|
|
1820
|
+
class ds extends Pe {
|
|
1815
1821
|
constructor(e, t) {
|
|
1816
1822
|
super(), this.buildRequest({ type: "debug_report_data", debug_report_id: e, debug_report_version: 1, debug_report_data: t });
|
|
1817
1823
|
}
|
|
@@ -1820,22 +1826,22 @@ function Vt(n, e) {
|
|
|
1820
1826
|
var t, i;
|
|
1821
1827
|
return { errorCode: n.errorCode, errorText: n.errorText, url: n.url, address: n.address, port: n.port, connectionState: e.connectionState, iceConnectionState: e.iceConnectionState, iceGatheringState: e.iceGatheringState, signalingState: e.signalingState, localDescriptionType: (t = e.localDescription) === null || t === void 0 ? void 0 : t.type, remoteDescriptionType: (i = e.remoteDescription) === null || i === void 0 ? void 0 : i.type };
|
|
1822
1828
|
}
|
|
1823
|
-
function
|
|
1829
|
+
function us(n, e) {
|
|
1824
1830
|
const t = ye();
|
|
1825
1831
|
let i = !1;
|
|
1826
|
-
const s = new
|
|
1832
|
+
const s = new os({ getStatsInterval: 1e3, rawStats: !1, statsObject: !0, filteredStats: !1, remote: !0, debug: !1, logLevel: "warn" }), o = (r) => O(this, void 0, void 0, (function* () {
|
|
1827
1833
|
r.event === "stats" && L(T.StatsFrame, (function({ data: c }) {
|
|
1828
1834
|
var u, l, f, h, S, y, v, E;
|
|
1829
|
-
const { audio: m, remote: w } = c, { audio: N } = w, A = (l = (u = N.inbound[0]) === null || u === void 0 ? void 0 : u.jitter) !== null && l !== void 0 ? l : 1 / 0, P = (h = (f = N.inbound[0]) === null || f === void 0 ? void 0 : f.roundTripTime) !== null && h !== void 0 ? h : 1 / 0, M = (y = (S = m.inbound[0]) === null || S === void 0 ? void 0 : S.packetsReceived) !== null && y !== void 0 ? y : -1, q = (E = (v = m.inbound[0]) === null || v === void 0 ? void 0 : v.packetsLost) !== null && E !== void 0 ? E : -1, F =
|
|
1830
|
-
return { jitter: A, rtt: P, mos: F, quality:
|
|
1831
|
-
})(r), n.uuid), yield n.execute(new
|
|
1835
|
+
const { audio: m, remote: w } = c, { audio: N } = w, A = (l = (u = N.inbound[0]) === null || u === void 0 ? void 0 : u.jitter) !== null && l !== void 0 ? l : 1 / 0, P = (h = (f = N.inbound[0]) === null || f === void 0 ? void 0 : f.roundTripTime) !== null && h !== void 0 ? h : 1 / 0, M = (y = (S = m.inbound[0]) === null || S === void 0 ? void 0 : S.packetsReceived) !== null && y !== void 0 ? y : -1, q = (E = (v = m.inbound[0]) === null || v === void 0 ? void 0 : v.packetsLost) !== null && E !== void 0 ? E : -1, F = rs({ jitter: 1e3 * A, rtt: 1e3 * P, packetsLost: q, packetsReceived: M });
|
|
1836
|
+
return { jitter: A, rtt: P, mos: F, quality: as(F), inboundAudio: m.inbound[0], outboundAudio: m.outbound[0], remoteInboundAudio: N.inbound[0], remoteOutboundAudio: N.outbound[0] };
|
|
1837
|
+
})(r), n.uuid), yield n.execute(new ds(t, r));
|
|
1832
1838
|
}));
|
|
1833
1839
|
return { get isRunning() {
|
|
1834
1840
|
return i;
|
|
1835
1841
|
}, start: (r, c, u) => O(this, void 0, void 0, (function* () {
|
|
1836
1842
|
if (i) g.debug(`[${e}] Stats reporter already running, skipping start`);
|
|
1837
1843
|
else {
|
|
1838
|
-
yield n.execute(new
|
|
1844
|
+
yield n.execute(new cs(t, e)), s.on("timeline", o);
|
|
1839
1845
|
try {
|
|
1840
1846
|
yield s.addConnection({ pc: r, peerId: c, connectionId: u }), i = !0;
|
|
1841
1847
|
} catch (l) {
|
|
@@ -1847,7 +1853,7 @@ function ds(n, e) {
|
|
|
1847
1853
|
L(T.StatsReport, c, n.uuid), r === "file" && (function(u, l) {
|
|
1848
1854
|
const f = new Blob([JSON.stringify(u)], { type: "application/json" }), h = URL.createObjectURL(f), S = document.createElement("a");
|
|
1849
1855
|
S.href = h, S.download = `${l}.json`, S.click(), URL.revokeObjectURL(h);
|
|
1850
|
-
})(c, `webrtc-stats-${t}-${Date.now()}`), yield n.execute(new
|
|
1856
|
+
})(c, `webrtc-stats-${t}-${Date.now()}`), yield n.execute(new ls(t, e)), s.removeAllPeers(), s.destroy(), i = !1;
|
|
1851
1857
|
})), reportConnectionStateChange: (r) => {
|
|
1852
1858
|
const c = { event: "connectionstatechange-detailed", tag: "connection", timestamp: (/* @__PURE__ */ new Date()).toISOString(), data: r };
|
|
1853
1859
|
o(c);
|
|
@@ -1856,10 +1862,10 @@ function ds(n, e) {
|
|
|
1856
1862
|
o(c);
|
|
1857
1863
|
} };
|
|
1858
1864
|
}
|
|
1859
|
-
const
|
|
1865
|
+
const Tn = (n, e) => {
|
|
1860
1866
|
const { contentType: t, canvasType: i, callID: s, canvasInfo: o = null, currentLayerIdx: r = -1 } = e;
|
|
1861
1867
|
o && i !== "mcu-personal-canvas" && delete o.memberID;
|
|
1862
|
-
const c = { type: re.conferenceUpdate, call: n.calls[s], canvasInfo:
|
|
1868
|
+
const c = { type: re.conferenceUpdate, call: n.calls[s], canvasInfo: hs(o), currentLayerIdx: r };
|
|
1863
1869
|
switch (t) {
|
|
1864
1870
|
case "layer-info": {
|
|
1865
1871
|
const u = Object.assign({ action: oe.LayerInfo }, c);
|
|
@@ -1872,10 +1878,10 @@ const In = (n, e) => {
|
|
|
1872
1878
|
break;
|
|
1873
1879
|
}
|
|
1874
1880
|
}
|
|
1875
|
-
},
|
|
1881
|
+
}, hs = (n) => {
|
|
1876
1882
|
const e = JSON.stringify(n).replace(/memberID/g, "participantId").replace(/ID"/g, 'Id"').replace(/POS"/g, 'Pos"');
|
|
1877
1883
|
return gn(e);
|
|
1878
|
-
}, qt = ["new-call-start", "new-peer", "get-user-media", "peer-creation-end", "start-negotiation", "create-offer", "create-answer", "set-local-description", "ice-gathering-started", "first-candidate", "first-non-host-candidate", "send-sdp", "ice-gathering-completed", "ringing", "telnyx-rtc-media", "first-remote-media-track", "set-remote-description", "telnyx-rtc-answer", "ice-connected", "dtls-connected", "call-active", "answer-called"],
|
|
1884
|
+
}, qt = ["new-call-start", "new-peer", "get-user-media", "peer-creation-end", "start-negotiation", "create-offer", "create-answer", "set-local-description", "ice-gathering-started", "first-candidate", "first-non-host-candidate", "send-sdp", "ice-gathering-completed", "ringing", "telnyx-rtc-media", "first-remote-media-track", "set-remote-description", "telnyx-rtc-answer", "ice-connected", "dtls-connected", "call-active", "answer-called"], ps = { "new-call-start": "Call Start", "new-peer": "Peer object created", "get-user-media": "Media devices acquired", "peer-creation-end": "Peer setup complete", "start-negotiation": "SDP negotiation started", "create-offer": "SDP offer generated", "create-answer": "SDP answer generated", "set-local-description": "Local description applied", "ice-gathering-started": "ICE candidate gathering started", "first-candidate": "First ICE candidate found", "first-non-host-candidate": "First server-reflexive/relay candidate found", "send-sdp": "SDP sent to server", "ice-gathering-completed": "All ICE candidates gathered", ringing: "Remote side ringing", "telnyx-rtc-media": "Early media received from server", "first-remote-media-track": "First remote audio/video track received", "set-remote-description": "Remote description applied", "telnyx-rtc-answer": "Call answered by remote side", "ice-connected": "ICE connection established", "dtls-connected": "Secure media channel established (DTLS)", "call-active": "Call is active", "answer-called": "Answer delay (invite → call.answer)" };
|
|
1879
1885
|
function Yt(n) {
|
|
1880
1886
|
try {
|
|
1881
1887
|
const e = performance.getEntriesByName(n, "mark");
|
|
@@ -1919,11 +1925,11 @@ class xe {
|
|
|
1919
1925
|
navigator.onLine ? c() : window.addEventListener("online", c);
|
|
1920
1926
|
}
|
|
1921
1927
|
if (r === "disconnected") {
|
|
1922
|
-
const c = ue(
|
|
1928
|
+
const c = ue(yi);
|
|
1923
1929
|
L(T.Warning, { warning: c, callId: this.options.id, sessionId: this._session.sessionid }, this.options.id);
|
|
1924
1930
|
}
|
|
1925
1931
|
if (r === "failed") {
|
|
1926
|
-
const c = ue(
|
|
1932
|
+
const c = ue(Ci);
|
|
1927
1933
|
L(T.PeerConnectionFailureError, { warning: c, error: new Error(`Peer Connection failed. previous state: ${this._prevConnectionState}, current state: ${r}`), sessionId: this._session.sessionid }, this.options.id);
|
|
1928
1934
|
}
|
|
1929
1935
|
this._prevConnectionState = r, r === "connected" && (performance.mark("dtls-connected"), this.tryCollectTimings()), this._isTrickleIce() && (r === "connecting" && performance.mark("peer-connection-connecting"), r === "connected" && (this._clearIceGatheringSafetyTimeout(), performance.mark("peer-connection-connected")));
|
|
@@ -1938,10 +1944,10 @@ class xe {
|
|
|
1938
1944
|
}, g.debug("New Peer with type:", this.type, "Options:", this.options), this._constraints = { offerToReceiveAudio: !0, offerToReceiveVideo: !!t.video }, this._sdpReady = this._sdpReady.bind(this), this.handleSignalingStateChangeEvent = this.handleSignalingStateChangeEvent.bind(this), this.handleNegotiationNeededEvent = this.handleNegotiationNeededEvent.bind(this), this.handleTrackEvent = this.handleTrackEvent.bind(this), this.createPeerConnection = this.createPeerConnection.bind(this), this._session = i, this._trickleIceSdpFn = s, this._registerPeerEvents = o;
|
|
1939
1945
|
}
|
|
1940
1946
|
get isOffer() {
|
|
1941
|
-
return this.type ===
|
|
1947
|
+
return this.type === Q.Offer;
|
|
1942
1948
|
}
|
|
1943
1949
|
get isAnswer() {
|
|
1944
|
-
return this.type ===
|
|
1950
|
+
return this.type === Q.Answer;
|
|
1945
1951
|
}
|
|
1946
1952
|
get isDebugEnabled() {
|
|
1947
1953
|
return this.options.debug || this._session.options.debug;
|
|
@@ -1998,7 +2004,7 @@ class xe {
|
|
|
1998
2004
|
for (const u of qt) {
|
|
1999
2005
|
if (u === "new-call-start") continue;
|
|
2000
2006
|
const l = Yt(u);
|
|
2001
|
-
l !== void 0 && o.push({ label:
|
|
2007
|
+
l !== void 0 && o.push({ label: ps[u] || u, fromStart: l - s });
|
|
2002
2008
|
}
|
|
2003
2009
|
o.sort(((u, l) => u.fromStart - l.fromStart));
|
|
2004
2010
|
const r = [];
|
|
@@ -2037,7 +2043,7 @@ class xe {
|
|
|
2037
2043
|
var e;
|
|
2038
2044
|
this.instance = (e = this._config(), new window.RTCPeerConnection(e)), this.instance.onsignalingstatechange = this.handleSignalingStateChangeEvent, this.instance.onnegotiationneeded = this.handleNegotiationNeededEvent, this.instance.ontrack = this.handleTrackEvent, this.instance.addEventListener("connectionstatechange", this.handleConnectionStateChange), this.instance.addEventListener("iceconnectionstatechange", this._handleIceConnectionStateChange), this.instance.addEventListener("icegatheringstatechange", this._handleIceGatheringStateChange), this.instance.addEventListener("addstream", ((s) => {
|
|
2039
2045
|
this.options.remoteStream = s.stream;
|
|
2040
|
-
})), this._registerPeerEvents(this.instance), this._prevConnectionState = this.instance.connectionState, this.isAnswer && (yield this._setRemoteDescription({ sdp: this.options.remoteSdp, type:
|
|
2046
|
+
})), this._registerPeerEvents(this.instance), this._prevConnectionState = this.instance.connectionState, this.isAnswer && (yield this._setRemoteDescription({ sdp: this.options.remoteSdp, type: Q.Offer }), performance.mark("set-remote-description"));
|
|
2041
2047
|
const t = !!this.options.receiveOnlyAudio && !this.options.audio;
|
|
2042
2048
|
let i = null;
|
|
2043
2049
|
if (this.options.localStream = yield this._retrieveLocalStream().catch(((s) => O(this, void 0, void 0, (function* () {
|
|
@@ -2071,10 +2077,10 @@ class xe {
|
|
|
2071
2077
|
this._clearIceGatheringSafetyTimeout(), this._iceGatheringSafetyTimeout = setTimeout((() => {
|
|
2072
2078
|
if (this.instance) {
|
|
2073
2079
|
if (this._gatheredCandidatesCount === 0) {
|
|
2074
|
-
const e = ue(
|
|
2080
|
+
const e = ue(bi);
|
|
2075
2081
|
L(T.Warning, { warning: e, callId: this.options.id, sessionId: this._session.sessionid }, this.options.id);
|
|
2076
2082
|
} else if (this.instance.iceGatheringState !== "complete") {
|
|
2077
|
-
const e = ue(
|
|
2083
|
+
const e = ue(Si);
|
|
2078
2084
|
L(T.Warning, { warning: e, callId: this.options.id, sessionId: this._session.sessionid }, this.options.id);
|
|
2079
2085
|
}
|
|
2080
2086
|
}
|
|
@@ -2086,7 +2092,7 @@ class xe {
|
|
|
2086
2092
|
init() {
|
|
2087
2093
|
var e;
|
|
2088
2094
|
return O(this, void 0, void 0, (function* () {
|
|
2089
|
-
yield this.createPeerConnection(), this.isDebugEnabled && (this.statsReporter =
|
|
2095
|
+
yield this.createPeerConnection(), this.isDebugEnabled && (this.statsReporter = us(this._session, this.options.id), yield (e = this.statsReporter) === null || e === void 0 ? void 0 : e.start(this.instance, this._session.sessionid, this._session.sessionid));
|
|
2090
2096
|
const { localElement: t, localStream: i = null, screenShare: s = !1 } = this.options;
|
|
2091
2097
|
if (me(i)) {
|
|
2092
2098
|
const o = i.getAudioTracks();
|
|
@@ -2161,14 +2167,14 @@ class xe {
|
|
|
2161
2167
|
_createAnswer() {
|
|
2162
2168
|
return O(this, void 0, void 0, (function* () {
|
|
2163
2169
|
if (this._isAnswer()) {
|
|
2164
|
-
if (this.instance.signalingState !== "stable" && this.instance.signalingState !== "have-remote-offer") return g.debug("Skipping negotiation, state:", this.instance.signalingState), g.debug(" - But the signaling state isn't stable, so triggering rollback"), void (yield Promise.all([this.instance.setLocalDescription({ type: "rollback" }), this.instance.setRemoteDescription({ sdp: this.options.remoteSdp, type:
|
|
2170
|
+
if (this.instance.signalingState !== "stable" && this.instance.signalingState !== "have-remote-offer") return g.debug("Skipping negotiation, state:", this.instance.signalingState), g.debug(" - But the signaling state isn't stable, so triggering rollback"), void (yield Promise.all([this.instance.setLocalDescription({ type: "rollback" }), this.instance.setRemoteDescription({ sdp: this.options.remoteSdp, type: Q.Offer })]));
|
|
2165
2171
|
this._logTransceivers();
|
|
2166
2172
|
try {
|
|
2167
2173
|
const e = yield this.instance.createAnswer();
|
|
2168
2174
|
return performance.mark("create-answer"), yield this._setLocalDescription(e), performance.mark("set-local-description"), performance.mark("ice-gathering-started"), e;
|
|
2169
2175
|
} catch (e) {
|
|
2170
2176
|
g.error("Peer _createAnswer error:", e);
|
|
2171
|
-
const t = W(
|
|
2177
|
+
const t = W(Zn, e);
|
|
2172
2178
|
L(T.Error, { error: t, sessionId: this._session.sessionid }, this.options.id);
|
|
2173
2179
|
}
|
|
2174
2180
|
}
|
|
@@ -2180,7 +2186,7 @@ class xe {
|
|
|
2180
2186
|
yield this.instance.setLocalDescription(e);
|
|
2181
2187
|
} catch (t) {
|
|
2182
2188
|
g.error("Peer _setLocalDescription error:", t);
|
|
2183
|
-
const i = W(
|
|
2189
|
+
const i = W(ei, t);
|
|
2184
2190
|
throw L(T.Error, { error: i, sessionId: this._session.sessionid }, this.options.id), t;
|
|
2185
2191
|
}
|
|
2186
2192
|
}));
|
|
@@ -2194,17 +2200,17 @@ class xe {
|
|
|
2194
2200
|
const e = yield (t = this.options, O(void 0, void 0, void 0, (function* () {
|
|
2195
2201
|
let { audio: i = !0, micId: s, video: o = !1, camId: r } = t;
|
|
2196
2202
|
const { micLabel: c = "", camLabel: u = "" } = t;
|
|
2197
|
-
return s && (s = yield
|
|
2203
|
+
return s && (s = yield Je(s, c, le.AudioIn).catch(((l) => null)), s && (typeof i == "boolean" && (i = {}), i.deviceId = { exact: s })), r && (r = yield Je(r, u, le.Video).catch(((l) => null)), r && (typeof o == "boolean" && (o = {}), o.deviceId = { exact: r })), { audio: i, video: o };
|
|
2198
2204
|
})));
|
|
2199
2205
|
var t;
|
|
2200
2206
|
return Ye(e);
|
|
2201
2207
|
}));
|
|
2202
2208
|
}
|
|
2203
2209
|
_isOffer() {
|
|
2204
|
-
return this.type ===
|
|
2210
|
+
return this.type === Q.Offer;
|
|
2205
2211
|
}
|
|
2206
2212
|
_isAnswer() {
|
|
2207
|
-
return this.type ===
|
|
2213
|
+
return this.type === Q.Answer;
|
|
2208
2214
|
}
|
|
2209
2215
|
_isTrickleIce() {
|
|
2210
2216
|
return this.options.trickleIce === !0;
|
|
@@ -2226,7 +2232,7 @@ class xe {
|
|
|
2226
2232
|
}
|
|
2227
2233
|
xe.ICE_GATHERING_SAFETY_TIMEOUT_MS = 15e3;
|
|
2228
2234
|
const je = bt;
|
|
2229
|
-
class
|
|
2235
|
+
class kn {
|
|
2230
2236
|
constructor(e, t) {
|
|
2231
2237
|
this.session = e, this._callReportCollector = null, this.id = "", this.recoveredCallId = "", this.state = U[U.New], this.prevState = "", this.channels = [], this.role = lt.Participant, this.extension = null, this._state = U.New, this._prevState = U.New, this.gotAnswer = !1, this.gotEarly = !1, this._lastSerno = 0, this._targetNodeId = null, this._iceTimeout = null, this._iceDone = !1, this._statsBindings = [], this._statsIntervalId = null, this._pendingIceCandidates = [], this._isRemoteDescriptionSet = !1, this._signalingStateClosed = !1, this._creatingPeer = !1, this._firstCandidateSent = !1, this._firstNonHostCandidateSent = !1, this._isRecovering = !1, this._checkConferenceSerno = (m) => {
|
|
2232
2238
|
const w = m < 0 || !this._lastSerno || this._lastSerno && m === this._lastSerno + 1;
|
|
@@ -2246,7 +2252,7 @@ class Tn {
|
|
|
2246
2252
|
}));
|
|
2247
2253
|
};
|
|
2248
2254
|
const { iceServers: i, speaker: s, micId: o, micLabel: r, camId: c, camLabel: u, localElement: l, remoteElement: f, options: h, mediaConstraints: { audio: S, video: y }, ringtoneFile: v, ringbackFile: E } = e;
|
|
2249
|
-
this.options = Object.assign({},
|
|
2255
|
+
this.options = Object.assign({}, ji, { audio: S, video: y, iceServers: t?.iceServers && Array.isArray(t.iceServers) ? t.iceServers : i, localElement: l, remoteElement: f, micId: o, micLabel: r, camId: c, camLabel: u, speakerId: s, ringtoneFile: v, ringbackFile: E, debug: h.debug, debugOutput: h.debugOutput, trickleIce: h.trickleIce, prefetchIceCandidates: h.prefetchIceCandidates, forceRelayCandidate: h.forceRelayCandidate, keepConnectionAliveOnSocketClose: h.keepConnectionAliveOnSocketClose, mutedMicOnStart: h.mutedMicOnStart }, t), this._onMediaError = this._onMediaError.bind(this), this._onPeerConnectionFailureError = this._onPeerConnectionFailureError.bind(this), this._onPeerConnectionSignalingStateClosed = this._onPeerConnectionSignalingStateClosed.bind(this), this._onTrickleIceSdp = this._onTrickleIceSdp.bind(this), this._registerPeerEvents = this._registerPeerEvents.bind(this), this._registerTrickleIcePeerEvents = this._registerTrickleIcePeerEvents.bind(this), this._init(), this.options && (this._ringtone = $t(this.options.ringtoneFile, "_ringtone"), this._ringback = $t(this.options.ringbackFile, "_ringback"));
|
|
2250
2256
|
}
|
|
2251
2257
|
get creatingPeer() {
|
|
2252
2258
|
return this._creatingPeer;
|
|
@@ -2276,11 +2282,11 @@ class Tn {
|
|
|
2276
2282
|
return `conference-member.${this.id}`;
|
|
2277
2283
|
}
|
|
2278
2284
|
get isAudioMuted() {
|
|
2279
|
-
return !
|
|
2285
|
+
return !ns(this.options.localStream);
|
|
2280
2286
|
}
|
|
2281
2287
|
invite() {
|
|
2282
2288
|
return O(this, void 0, void 0, (function* () {
|
|
2283
|
-
this._creatingPeer = !0, this.direction = ce.Outbound, this.options.trickleIce && this._resetTrickleIceCandidateState(), performance.mark("new-peer"), this.peer = new xe(
|
|
2289
|
+
this._creatingPeer = !0, this.direction = ce.Outbound, this.options.trickleIce && this._resetTrickleIceCandidateState(), performance.mark("new-peer"), this.peer = new xe(Q.Offer, this.options, this.session, this._onTrickleIceSdp, this.options.trickleIce ? this._registerTrickleIcePeerEvents : this._registerPeerEvents);
|
|
2284
2290
|
try {
|
|
2285
2291
|
yield this.peer.init();
|
|
2286
2292
|
} catch (e) {
|
|
@@ -2294,7 +2300,7 @@ class Tn {
|
|
|
2294
2300
|
answer(e = {}) {
|
|
2295
2301
|
var t;
|
|
2296
2302
|
return O(this, void 0, void 0, (function* () {
|
|
2297
|
-
performance.mark("answer-called"), this._creatingPeer = !0, this.stopRingtone(), this.direction = ce.Inbound, ((t = e?.customHeaders) === null || t === void 0 ? void 0 : t.length) > 0 && (this.options = Object.assign(Object.assign({}, this.options), { customHeaders: e.customHeaders })), this.options.trickleIce && this._resetTrickleIceCandidateState(), performance.mark("new-peer"), this.peer = new xe(
|
|
2303
|
+
performance.mark("answer-called"), this._creatingPeer = !0, this.stopRingtone(), this.direction = ce.Inbound, ((t = e?.customHeaders) === null || t === void 0 ? void 0 : t.length) > 0 && (this.options = Object.assign(Object.assign({}, this.options), { customHeaders: e.customHeaders })), this.options.trickleIce && this._resetTrickleIceCandidateState(), performance.mark("new-peer"), this.peer = new xe(Q.Answer, this.options, this.session, this._onTrickleIceSdp, this.options.trickleIce ? this._registerTrickleIcePeerEvents : this._registerPeerEvents);
|
|
2298
2304
|
try {
|
|
2299
2305
|
yield this.peer.init();
|
|
2300
2306
|
} catch (i) {
|
|
@@ -2323,12 +2329,12 @@ class Tn {
|
|
|
2323
2329
|
const c = e || {}, u = t !== !1, l = this._state < U.Active ? { cause: "USER_BUSY", causeCode: 17 } : { cause: "NORMAL_CLEARING", causeCode: 16 };
|
|
2324
2330
|
if (this.cause = c.cause || l.cause, this.causeCode = c.causeCode || l.causeCode, this.sipCode = c.sipCode || null, this.sipReason = c.sipReason || null, this.sipCallId = c.sip_call_id || null, this.options.customHeaders = [...(i = this.options.customHeaders) !== null && i !== void 0 ? i : [], ...(o = (s = c?.dialogParams) === null || s === void 0 ? void 0 : s.customHeaders) !== null && o !== void 0 ? o : []], c.isRecovering) return this._isRecovering = !0, this.setState(U.Recovering), void this._finalize();
|
|
2325
2331
|
if (this.setState(U.Hangup), this.stopRingtone(), this.stopRingback(), u) {
|
|
2326
|
-
const f = new
|
|
2332
|
+
const f = new Yi({ sipCode: this.sipCode, sip_call_id: this.sipCallId, sessid: this.session.sessionid, dialogParams: this.options, cause: this.cause, causeCode: this.causeCode });
|
|
2327
2333
|
try {
|
|
2328
2334
|
yield this._execute(f);
|
|
2329
2335
|
} catch (h) {
|
|
2330
2336
|
g.error("telnyx_rtc.bye failed!", h);
|
|
2331
|
-
const S = W(
|
|
2337
|
+
const S = W(oi, h);
|
|
2332
2338
|
L(T.Error, { error: S, callId: this.id, sessionId: this.session.sessionid }, this.session.uuid);
|
|
2333
2339
|
}
|
|
2334
2340
|
}
|
|
@@ -2449,7 +2455,7 @@ class Tn {
|
|
|
2449
2455
|
case U.Active:
|
|
2450
2456
|
performance.mark("call-active"), (t = this.peer) === null || t === void 0 || t.tryCollectTimings(), this._isRecovering && (this._isRecovering = !1, g.debug(`[${this.id}] Recovery complete, call is active`)), setTimeout((() => {
|
|
2451
2457
|
const { remoteElement: s, speakerId: o } = this.options;
|
|
2452
|
-
s && o &&
|
|
2458
|
+
s && o && En(s, o);
|
|
2453
2459
|
}), 0), this._callReportCollector && (!((i = this.peer) === null || i === void 0) && i.instance) && this.session.callReportId && this._callReportCollector.start(this.peer.instance);
|
|
2454
2460
|
break;
|
|
2455
2461
|
case U.Destroy:
|
|
@@ -2544,7 +2550,7 @@ class Tn {
|
|
|
2544
2550
|
return O(this, void 0, void 0, (function* () {
|
|
2545
2551
|
const t = { nodeId: this.nodeId, channels: [e], handler: (s) => {
|
|
2546
2552
|
const { eventData: o } = s;
|
|
2547
|
-
o.contentType === "layout-info" ? (o.callID = this.id,
|
|
2553
|
+
o.contentType === "layout-info" ? (o.callID = this.id, Tn(this.session, o)) : g.error("Conference-Info unknown contentType", s);
|
|
2548
2554
|
} }, i = yield this.session.vertoSubscribe(t).catch(((s) => {
|
|
2549
2555
|
g.error("ConfInfo subscription error:", s);
|
|
2550
2556
|
}));
|
|
@@ -2560,12 +2566,12 @@ class Tn {
|
|
|
2560
2566
|
}
|
|
2561
2567
|
_handleChangeHoldStateError(e) {
|
|
2562
2568
|
g.error(`Failed to ${e.action} on call ${this.id}`);
|
|
2563
|
-
const t = W(
|
|
2569
|
+
const t = W(ii, e);
|
|
2564
2570
|
return L(T.Error, { error: t, callId: this.id, sessionId: this.session.sessionid }, this.session.uuid), !1;
|
|
2565
2571
|
}
|
|
2566
2572
|
_onRemoteSdp(e) {
|
|
2567
2573
|
return O(this, void 0, void 0, (function* () {
|
|
2568
|
-
const t = new RTCSessionDescription({ sdp: e, type:
|
|
2574
|
+
const t = new RTCSessionDescription({ sdp: e, type: Q.Answer });
|
|
2569
2575
|
yield this.peer.instance.setRemoteDescription(t).then((() => {
|
|
2570
2576
|
performance.mark("set-remote-description"), this.options.trickleIce && (this._isRemoteDescriptionSet = !0, this._flushPendingTrickleIceCandidates()), this.gotEarly && this.setState(U.Early), this.gotAnswer && this.setState(U.Active);
|
|
2571
2577
|
})).catch(((i) => O(this, void 0, void 0, (function* () {
|
|
@@ -2589,18 +2595,18 @@ class Tn {
|
|
|
2589
2595
|
const { sdp: s, type: o } = e;
|
|
2590
2596
|
if (s.indexOf("candidate") === -1) return g.info(`No candidate - retry
|
|
2591
2597
|
`), void this._requestAnotherLocalDescription();
|
|
2592
|
-
if ((i = (t = this.peer) === null || t === void 0 ? void 0 : t.instance) === null || i === void 0 || i.removeEventListener("icecandidate", this._onIce), !
|
|
2593
|
-
const u = ue(
|
|
2598
|
+
if ((i = (t = this.peer) === null || t === void 0 ? void 0 : t.instance) === null || i === void 0 || i.removeEventListener("icecandidate", this._onIce), !Ti.test(s)) {
|
|
2599
|
+
const u = ue(wi);
|
|
2594
2600
|
g.warn(`[${this.id}] Warning ${u.code}: ${u.message}`), L(T.Warning, { warning: u, callId: this.id, sessionId: this.session.sessionid }, this.session.uuid);
|
|
2595
2601
|
}
|
|
2596
2602
|
performance.mark("ice-gathering-end");
|
|
2597
2603
|
let r = null;
|
|
2598
2604
|
const c = { sessid: this.session.sessionid, sdp: s, dialogParams: this.options, "User-Agent": `Web-${je}` };
|
|
2599
2605
|
switch (o) {
|
|
2600
|
-
case
|
|
2606
|
+
case Q.Offer:
|
|
2601
2607
|
this.setState(U.Requesting), r = new Dt(c);
|
|
2602
2608
|
break;
|
|
2603
|
-
case
|
|
2609
|
+
case Q.Answer:
|
|
2604
2610
|
this._isRecovering || this.setState(U.Answering), r = this.options.attach === !0 ? new Mt(c) : new Pt(c);
|
|
2605
2611
|
break;
|
|
2606
2612
|
default:
|
|
@@ -2608,7 +2614,7 @@ class Tn {
|
|
|
2608
2614
|
}
|
|
2609
2615
|
performance.mark("send-sdp"), this._execute(r).then(((u) => {
|
|
2610
2616
|
const { node_id: l = null } = u;
|
|
2611
|
-
this._targetNodeId = l, o ===
|
|
2617
|
+
this._targetNodeId = l, o === Q.Offer ? this.setState(U.Trying) : this.setState(U.Active);
|
|
2612
2618
|
})).catch(((u) => O(this, void 0, void 0, (function* () {
|
|
2613
2619
|
g.error(`${this.id} - Sending ${o} error:`, u);
|
|
2614
2620
|
const l = W(Et, u);
|
|
@@ -2626,10 +2632,10 @@ class Tn {
|
|
|
2626
2632
|
let s = null;
|
|
2627
2633
|
const o = { sessid: this.session.sessionid, sdp: t, dialogParams: this.options, trickle: !0, "User-Agent": `Web-${je}` };
|
|
2628
2634
|
switch (i) {
|
|
2629
|
-
case
|
|
2635
|
+
case Q.Offer:
|
|
2630
2636
|
this.setState(U.Requesting), s = new Dt(o);
|
|
2631
2637
|
break;
|
|
2632
|
-
case
|
|
2638
|
+
case Q.Answer:
|
|
2633
2639
|
this._isRecovering || this.setState(U.Answering), s = this.options.attach === !0 ? new Mt(o) : new Pt(o);
|
|
2634
2640
|
break;
|
|
2635
2641
|
default:
|
|
@@ -2637,7 +2643,7 @@ class Tn {
|
|
|
2637
2643
|
}
|
|
2638
2644
|
performance.mark("send-sdp"), this._execute(s).then(((r) => {
|
|
2639
2645
|
const { node_id: c = null } = r;
|
|
2640
|
-
this._targetNodeId = c, i ===
|
|
2646
|
+
this._targetNodeId = c, i === Q.Offer ? this.setState(U.Trying) : this.setState(U.Active);
|
|
2641
2647
|
})).catch(((r) => O(this, void 0, void 0, (function* () {
|
|
2642
2648
|
g.error(`${this.id} - Sending ${i} error:`, r);
|
|
2643
2649
|
const c = W(Et, r);
|
|
@@ -2663,7 +2669,7 @@ class Tn {
|
|
|
2663
2669
|
e.candidate && e.candidate.candidate ? (g.debug("RTCPeer Candidate:", e.candidate), (t = this.peer) === null || t === void 0 || t.incrementGatheredCandidates(), this._trackCandidateMarks(e.candidate), this._sendIceCandidate(e.candidate)) : this._sendEndOfCandidates();
|
|
2664
2670
|
}
|
|
2665
2671
|
_sendIceCandidate(e) {
|
|
2666
|
-
const t = new
|
|
2672
|
+
const t = new Ji({ sessid: this.session.sessionid, candidate: e.candidate, sdpMLineIndex: e.sdpMLineIndex, sdpMid: e.sdpMid, dialogParams: this.options });
|
|
2667
2673
|
this._execute(t);
|
|
2668
2674
|
}
|
|
2669
2675
|
_addIceCandidate(e) {
|
|
@@ -2762,7 +2768,7 @@ class Tn {
|
|
|
2762
2768
|
var u;
|
|
2763
2769
|
this.options.id = i ? i.toString() : ye(), this.id = this.options.id, c && (this.recoveredCallId = c, this._isRecovering = !0), s && (u = s, Object.keys(u).length !== 0) || (this.options.userVariables = this.session.options.userVariables || {}), o || (this.options.remoteCallerNumber = this.options.destinationNumber), this.session.calls[this.id] = this, he(T.MediaError, this._onMediaError, this.id), he(T.PeerConnectionFailureError, this._onPeerConnectionFailureError, this.id), he(T.PeerConnectionSignalingStateClosed, this._onPeerConnectionSignalingStateClosed, this.id), Se(r) && he(T.Notification, r.bind(this), this.id);
|
|
2764
2770
|
const l = this.session.options.enableCallReports !== !1, f = this.session.options.callReportInterval || 5e3, h = this.session.options.debugLogLevel || "debug", S = this.session.options.debugLogMaxEntries || 1e3;
|
|
2765
|
-
l && (this._callReportCollector = new
|
|
2771
|
+
l && (this._callReportCollector = new J({ enabled: !0, interval: f }, { enabled: !0, level: h, maxEntries: S }), this._callReportCollector.onFlushNeeded = () => {
|
|
2766
2772
|
this._flushIntermediateReport();
|
|
2767
2773
|
}, this._callReportCollector.onWarning = (y) => {
|
|
2768
2774
|
L(T.Warning, { warning: y, callId: this.id, sessionId: this.session.sessionid }, this.session.uuid);
|
|
@@ -2815,7 +2821,7 @@ class Tn {
|
|
|
2815
2821
|
this._statsIntervalId && (clearInterval(this._statsIntervalId), this._statsIntervalId = null), g.debug("Stats stopped");
|
|
2816
2822
|
}
|
|
2817
2823
|
}
|
|
2818
|
-
|
|
2824
|
+
kn.setStateTelnyx = (n) => {
|
|
2819
2825
|
if (n) {
|
|
2820
2826
|
switch (n._state) {
|
|
2821
2827
|
case U.Recovering:
|
|
@@ -2845,9 +2851,9 @@ Tn.setStateTelnyx = (n) => {
|
|
|
2845
2851
|
return n;
|
|
2846
2852
|
}
|
|
2847
2853
|
};
|
|
2848
|
-
class ge extends
|
|
2854
|
+
class ge extends kn {
|
|
2849
2855
|
constructor() {
|
|
2850
|
-
super(...arguments), this._statsInterval = null, this.sendConversationMessage = (e, t) => this.session.execute(new
|
|
2856
|
+
super(...arguments), this._statsInterval = null, this.sendConversationMessage = (e, t) => this.session.execute(new ss(e, t));
|
|
2851
2857
|
}
|
|
2852
2858
|
hangup(e = {}, t = !0) {
|
|
2853
2859
|
const i = Object.create(null, { hangup: { get: () => super.hangup } });
|
|
@@ -2877,7 +2883,7 @@ class ge extends Tn {
|
|
|
2877
2883
|
return O(this, void 0, void 0, (function* () {
|
|
2878
2884
|
this.options.speakerId = e;
|
|
2879
2885
|
const { remoteElement: t, speakerId: i } = this.options;
|
|
2880
|
-
return !(!t || !i) &&
|
|
2886
|
+
return !(!t || !i) && En(t, i);
|
|
2881
2887
|
}));
|
|
2882
2888
|
}
|
|
2883
2889
|
_finalize() {
|
|
@@ -2900,7 +2906,7 @@ ${r.type}
|
|
|
2900
2906
|
}))), 2e3);
|
|
2901
2907
|
}
|
|
2902
2908
|
}
|
|
2903
|
-
class
|
|
2909
|
+
class fs extends Le {
|
|
2904
2910
|
constructor(e) {
|
|
2905
2911
|
super(e), this.calls = {}, this.autoRecoverCalls = !0, this._iceServers = [], this._localElement = null, this._remoteElement = null, this._jwtAuth = !0, this._audioConstraints = !0, this._previousAudioConstraints = !0, this._videoConstraints = !1, this._speaker = null, this._onlineHandler = null, this._offlineHandler = null, this._wasOffline = !1, this._videoConstraints = e.video || !1, this.iceServers = e.iceServers, this.ringtoneFile = e.ringtoneFile, this.ringbackFile = e.ringbackFile, this._setupNetworkListeners();
|
|
2906
2912
|
}
|
|
@@ -2962,7 +2968,7 @@ class ps extends Le {
|
|
|
2962
2968
|
}
|
|
2963
2969
|
speedTest(e) {
|
|
2964
2970
|
return new Promise(((t, i) => {
|
|
2965
|
-
if (
|
|
2971
|
+
if (Sn(T.SpeedTest, ((r) => {
|
|
2966
2972
|
const { upDur: c, downDur: u } = r, l = u ? 8 * e / (u / 1e3) / 1024 : 0;
|
|
2967
2973
|
t({ upDur: c, downDur: u, upKps: (c ? 8 * e / (c / 1e3) / 1024 : 0).toFixed(0), downKps: l.toFixed(0) });
|
|
2968
2974
|
}), this.uuid), !(e = Number(e))) return i(`Invalid parameter 'bytes': ${e}`);
|
|
@@ -2993,7 +2999,7 @@ class ps extends Le {
|
|
|
2993
2999
|
return Te(le.AudioOut).catch(((e) => (g.error("getAudioOutDevices", e), L(T.MediaError, e, this.uuid), [])));
|
|
2994
3000
|
}
|
|
2995
3001
|
validateDeviceId(e, t, i) {
|
|
2996
|
-
return
|
|
3002
|
+
return Je(e, t, i);
|
|
2997
3003
|
}
|
|
2998
3004
|
getDeviceResolutions(e) {
|
|
2999
3005
|
return O(this, void 0, void 0, (function* () {
|
|
@@ -3018,10 +3024,10 @@ class ps extends Le {
|
|
|
3018
3024
|
return O(this, void 0, void 0, (function* () {
|
|
3019
3025
|
if (!e) throw new Error("You need to provide the settings object");
|
|
3020
3026
|
const { micId: t, micLabel: i } = e, s = He(e, ["micId", "micLabel"]);
|
|
3021
|
-
return
|
|
3027
|
+
return ts(s), this._audioConstraints = yield ((o, r, c, u) => O(void 0, void 0, void 0, (function* () {
|
|
3022
3028
|
const { deviceId: l } = u;
|
|
3023
3029
|
if (l === void 0 && (o || r)) {
|
|
3024
|
-
const f = yield
|
|
3030
|
+
const f = yield Je(o, r, c).catch(((h) => null));
|
|
3025
3031
|
f && (u.deviceId = { exact: f });
|
|
3026
3032
|
}
|
|
3027
3033
|
return u;
|
|
@@ -3038,7 +3044,7 @@ class ps extends Le {
|
|
|
3038
3044
|
if (e && Array.isArray(e)) this._iceServers = e;
|
|
3039
3045
|
else {
|
|
3040
3046
|
const t = this.options.env === "development";
|
|
3041
|
-
this._iceServers = t ?
|
|
3047
|
+
this._iceServers = t ? Ai : Ri;
|
|
3042
3048
|
}
|
|
3043
3049
|
}
|
|
3044
3050
|
get iceServers() {
|
|
@@ -3064,13 +3070,13 @@ class ps extends Le {
|
|
|
3064
3070
|
}
|
|
3065
3071
|
vertoBroadcast({ nodeId: e, channel: t = "", data: i }) {
|
|
3066
3072
|
if (!t) throw new Error(`Invalid channel for broadcast: ${t}`);
|
|
3067
|
-
const s = new
|
|
3073
|
+
const s = new zi({ sessid: this.sessionid, eventChannel: t, data: i });
|
|
3068
3074
|
e && (s.targetNodeId = e), this.execute(s).catch(((o) => o));
|
|
3069
3075
|
}
|
|
3070
3076
|
vertoSubscribe({ nodeId: e, channels: t = [], handler: i }) {
|
|
3071
3077
|
return O(this, void 0, void 0, (function* () {
|
|
3072
3078
|
if (!(t = t.filter(((u) => u && !this._existsSubscription(this.relayProtocol, u)))).length) return {};
|
|
3073
|
-
const s = new
|
|
3079
|
+
const s = new Qi({ sessid: this.sessionid, eventChannel: t });
|
|
3074
3080
|
e && (s.targetNodeId = e);
|
|
3075
3081
|
const o = yield this.execute(s), { unauthorized: r = [], subscribed: c = [] } = ut(o);
|
|
3076
3082
|
return r.length && r.forEach(((u) => this._removeSubscription(this.relayProtocol, u))), c.forEach(((u) => this._addSubscription(this.relayProtocol, i, u))), o;
|
|
@@ -3090,7 +3096,7 @@ class ps extends Le {
|
|
|
3090
3096
|
this._wasOffline && (g.debug(`Network connectivity restored for session ${this.sessionid}. Reconnecting...`), this._wasOffline = !1, this._autoReconnect = !0, this.socketDisconnect());
|
|
3091
3097
|
}, this._offlineHandler = () => {
|
|
3092
3098
|
this._wasOffline = !0, g.debug(`Network connectivity lost for session ${this.sessionid}`);
|
|
3093
|
-
const e = W(
|
|
3099
|
+
const e = W(pi);
|
|
3094
3100
|
L(T.Error, { error: e, sessionId: this.sessionid }, this.uuid);
|
|
3095
3101
|
}, window.addEventListener("online", this._onlineHandler), window.addEventListener("offline", this._offlineHandler));
|
|
3096
3102
|
}
|
|
@@ -3101,17 +3107,17 @@ class ps extends Le {
|
|
|
3101
3107
|
return ge.setStateTelnyx(e);
|
|
3102
3108
|
}
|
|
3103
3109
|
}
|
|
3104
|
-
class
|
|
3110
|
+
class Jt {
|
|
3105
3111
|
constructor(e, t) {
|
|
3106
3112
|
this.code = t, this.message = e;
|
|
3107
3113
|
}
|
|
3108
3114
|
}
|
|
3109
|
-
class
|
|
3115
|
+
class gs {
|
|
3110
3116
|
constructor(e) {
|
|
3111
3117
|
this.session = e, this.retriedConnect = 0, this.retriedRegister = 0;
|
|
3112
3118
|
}
|
|
3113
3119
|
_ack(e, t) {
|
|
3114
|
-
const i = new
|
|
3120
|
+
const i = new qi(e, t);
|
|
3115
3121
|
this.nodeId && (i.targetNodeId = this.nodeId), this.session.execute(i);
|
|
3116
3122
|
}
|
|
3117
3123
|
reconnectDelay() {
|
|
@@ -3123,7 +3129,7 @@ class fs {
|
|
|
3123
3129
|
h.setPingReceived();
|
|
3124
3130
|
const { id: S, method: y, params: v = {}, voice_sdk_id: E } = e, m = v?.callID, w = v?.eventChannel, N = v?.eventType, A = h.calls[m], P = (t = A?.peer) === null || t === void 0 ? void 0 : t.isConnectionHealthy();
|
|
3125
3131
|
if (Array.isArray(v?.reattached_sessions) && v.reattached_sessions.length === 0 && Object.keys(h.calls).length > 0) {
|
|
3126
|
-
const R = ue(
|
|
3132
|
+
const R = ue(Ii);
|
|
3127
3133
|
L(T.Warning, { warning: R, sessionId: h.sessionid }, h.uuid);
|
|
3128
3134
|
}
|
|
3129
3135
|
if (N === "channelPvtData") return this._handlePvtEvent(v.pvtData);
|
|
@@ -3133,7 +3139,7 @@ class fs {
|
|
|
3133
3139
|
m && (I.id = m), v.telnyx_call_control_id && (I.telnyxCallControlId = v.telnyx_call_control_id), v.telnyx_session_id && (I.telnyxSessionId = v.telnyx_session_id), v.telnyx_leg_id && (I.telnyxLegId = v.telnyx_leg_id), v.client_state && (I.clientState = v.client_state), v.dialogParams && v.dialogParams.custom_headers && v.dialogParams.custom_headers.length && (I.customHeaders = v.dialogParams.custom_headers), R && (I.recoveredCallId = R), performance.mark("new-call-start");
|
|
3134
3140
|
const x = new ge(h, I);
|
|
3135
3141
|
return x.nodeId = this.nodeId, x;
|
|
3136
|
-
}, q = new
|
|
3142
|
+
}, q = new bn(E), F = new Cn(E);
|
|
3137
3143
|
switch (y) {
|
|
3138
3144
|
case $.Answer:
|
|
3139
3145
|
case $.Display:
|
|
@@ -3194,7 +3200,7 @@ class fs {
|
|
|
3194
3200
|
case ne.NOREG:
|
|
3195
3201
|
if (this.retriedRegister += 1, this.retriedRegister === 5) {
|
|
3196
3202
|
this.retriedRegister = 0;
|
|
3197
|
-
const p = new
|
|
3203
|
+
const p = new Jt("Fail to register the user, the server tried 5 times", "UNREGED|NOREG"), _ = W(dn, p);
|
|
3198
3204
|
L(T.Error, { error: _, sessionId: h.sessionid }, h.uuid);
|
|
3199
3205
|
break;
|
|
3200
3206
|
}
|
|
@@ -3205,10 +3211,10 @@ class fs {
|
|
|
3205
3211
|
case ne.FAILED:
|
|
3206
3212
|
case ne.FAIL_WAIT:
|
|
3207
3213
|
if (h.connection.previousGatewayState !== ne.FAILED && h.connection.previousGatewayState !== ne.FAIL_WAIT) {
|
|
3208
|
-
const p = W(
|
|
3214
|
+
const p = W(di, new Error(`Gateway state: ${d}`));
|
|
3209
3215
|
if (L(T.Error, { error: p, sessionId: h.sessionid }, h.uuid), !this.session.hasAutoReconnect()) {
|
|
3210
3216
|
this.retriedConnect = 0;
|
|
3211
|
-
const _ = new
|
|
3217
|
+
const _ = new Jt("Fail to connect the server, the server tried 5 times", "FAILED|FAIL_WAIT"), b = W(li, _);
|
|
3212
3218
|
L(T.Error, { error: b, sessionId: h.sessionid }, h.uuid);
|
|
3213
3219
|
break;
|
|
3214
3220
|
}
|
|
@@ -3267,7 +3273,7 @@ class fs {
|
|
|
3267
3273
|
}
|
|
3268
3274
|
} }, E = yield t.vertoSubscribe(v).catch(((m) => {
|
|
3269
3275
|
g.error("liveArray subscription error:", m);
|
|
3270
|
-
const w = W(
|
|
3276
|
+
const w = W(ri, m);
|
|
3271
3277
|
L(T.Error, { error: w, sessionId: t.sessionid }, t.uuid);
|
|
3272
3278
|
}));
|
|
3273
3279
|
dt(E, o) && y();
|
|
@@ -3297,7 +3303,7 @@ class fs {
|
|
|
3297
3303
|
switch (e.contentType) {
|
|
3298
3304
|
case "layout-info":
|
|
3299
3305
|
case "layer-info":
|
|
3300
|
-
|
|
3306
|
+
Tn(this.session, e);
|
|
3301
3307
|
break;
|
|
3302
3308
|
case "logo-info": {
|
|
3303
3309
|
const t = { type: re.conferenceUpdate, action: oe.LogoInfo, logo: e.logoURL };
|
|
@@ -3307,7 +3313,7 @@ class fs {
|
|
|
3307
3313
|
}
|
|
3308
3314
|
}
|
|
3309
3315
|
}
|
|
3310
|
-
class
|
|
3316
|
+
class vs extends fs {
|
|
3311
3317
|
constructor(e) {
|
|
3312
3318
|
super(e), this.relayProtocol = "verto-protocol", this.timeoutErrorCode = -329990, this.handleLoginOnSocketOpen = () => O(this, void 0, void 0, (function* () {
|
|
3313
3319
|
this._idle = !1;
|
|
@@ -3317,7 +3323,7 @@ class gs extends ps {
|
|
|
3317
3323
|
} });
|
|
3318
3324
|
})), this.handleAnonymousLoginOnSocketOpen = () => O(this, void 0, void 0, (function* () {
|
|
3319
3325
|
this._idle = !1, yield this.login();
|
|
3320
|
-
})), this._vertoHandler = new
|
|
3326
|
+
})), this._vertoHandler = new gs(this), window.addEventListener("beforeunload", ((t) => {
|
|
3321
3327
|
this.calls && Object.keys(this.calls).forEach(((i) => {
|
|
3322
3328
|
this.calls[i] && (g.info(`Hanging up call due to window unload: ${i}`), this.calls[i].hangup({}, !0));
|
|
3323
3329
|
}));
|
|
@@ -3328,7 +3334,7 @@ class gs extends ps {
|
|
|
3328
3334
|
}
|
|
3329
3335
|
newCall(e) {
|
|
3330
3336
|
if (!this.validateCallOptions(e))
|
|
3331
|
-
throw W(
|
|
3337
|
+
throw W(si, void 0, "Error: destinationNumber is required");
|
|
3332
3338
|
const t = new ge(this, e);
|
|
3333
3339
|
return performance.mark("new-call-start"), t.invite(), t;
|
|
3334
3340
|
}
|
|
@@ -3353,26 +3359,26 @@ class gs extends ps {
|
|
|
3353
3359
|
this._vertoHandler.handleMessage(e);
|
|
3354
3360
|
}
|
|
3355
3361
|
}
|
|
3356
|
-
class
|
|
3362
|
+
class ms extends vs {
|
|
3357
3363
|
constructor(e) {
|
|
3358
|
-
super(e), g.info(`SDK version: ${
|
|
3364
|
+
super(e), g.info(`SDK version: ${wn}`);
|
|
3359
3365
|
}
|
|
3360
3366
|
newCall(e) {
|
|
3361
3367
|
return super.newCall(e);
|
|
3362
3368
|
}
|
|
3363
3369
|
static webRTCInfo() {
|
|
3364
|
-
return
|
|
3370
|
+
return is();
|
|
3365
3371
|
}
|
|
3366
3372
|
static webRTCSupportedBrowserList() {
|
|
3367
3373
|
return [{ operationSystem: "Android", supported: [{ browserName: "Chrome", features: ["audio"], supported: Y.full }, { browserName: "Firefox", features: ["audio"], supported: Y.partial }, { browserName: "Safari", supported: Y.not_supported }, { browserName: "Edge", supported: Y.not_supported }] }, { operationSystem: "iOS", supported: [{ browserName: "Chrome", supported: Y.not_supported }, { browserName: "Firefox", supported: Y.not_supported }, { browserName: "Safari", features: ["video", "audio"], supported: Y.full }, { browserName: "Edge", supported: Y.not_supported }] }, { operationSystem: "Linux", supported: [{ browserName: "Chrome", features: ["video", "audio"], supported: Y.full }, { browserName: "Firefox", features: ["audio"], supported: Y.partial }, { browserName: "Safari", supported: Y.not_supported }, { browserName: "Edge", supported: Y.not_supported }] }, { operationSystem: "MacOS", supported: [{ browserName: "Chrome", features: ["video", "audio"], supported: Y.full }, { browserName: "Firefox", features: ["audio"], supported: Y.partial }, { browserName: "Safari", features: ["video", "audio"], supported: Y.full }, { browserName: "Edge", features: ["audio"], supported: Y.partial }] }, { operationSystem: "Windows", supported: [{ browserName: "Chrome", features: ["video", "audio"], supported: Y.full }, { browserName: "Firefox", features: ["audio"], supported: Y.partial }, { browserName: "Safari", supported: Y.not_supported }, { browserName: "Edge", features: ["audio"], supported: Y.partial }] }];
|
|
3368
3374
|
}
|
|
3369
3375
|
}
|
|
3370
|
-
function
|
|
3376
|
+
function Rn(n) {
|
|
3371
3377
|
return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
|
|
3372
3378
|
}
|
|
3373
|
-
var at = { exports: {} },
|
|
3374
|
-
function
|
|
3375
|
-
return
|
|
3379
|
+
var at = { exports: {} }, Kt;
|
|
3380
|
+
function _s() {
|
|
3381
|
+
return Kt || (Kt = 1, (function(n) {
|
|
3376
3382
|
var e = Object.prototype.hasOwnProperty, t = "~";
|
|
3377
3383
|
function i() {
|
|
3378
3384
|
}
|
|
@@ -3477,14 +3483,14 @@ function ms() {
|
|
|
3477
3483
|
}, c.prototype.off = c.prototype.removeListener, c.prototype.addListener = c.prototype.on, c.prefixed = t, c.EventEmitter = c, n.exports = c;
|
|
3478
3484
|
})(at)), at.exports;
|
|
3479
3485
|
}
|
|
3480
|
-
var
|
|
3481
|
-
const Ct = /* @__PURE__ */
|
|
3482
|
-
var $e = { exports: {} },
|
|
3483
|
-
function
|
|
3486
|
+
var ys = _s();
|
|
3487
|
+
const Ct = /* @__PURE__ */ Rn(ys), Ke = new Ct();
|
|
3488
|
+
var $e = { exports: {} }, Ss = $e.exports, zt;
|
|
3489
|
+
function bs() {
|
|
3484
3490
|
return zt || (zt = 1, (function(n) {
|
|
3485
3491
|
(function(e, t) {
|
|
3486
3492
|
n.exports ? n.exports = t() : e.log = t();
|
|
3487
|
-
})(
|
|
3493
|
+
})(Ss, function() {
|
|
3488
3494
|
var e = function() {
|
|
3489
3495
|
}, t = "undefined", i = typeof window !== t && typeof window.navigator !== t && /Trident\/|MSIE /.test(window.navigator.userAgent), s = [
|
|
3490
3496
|
"trace",
|
|
@@ -3627,24 +3633,24 @@ function Ss() {
|
|
|
3627
3633
|
});
|
|
3628
3634
|
})($e)), $e.exports;
|
|
3629
3635
|
}
|
|
3630
|
-
var
|
|
3631
|
-
const
|
|
3636
|
+
var Cs = bs();
|
|
3637
|
+
const ws = /* @__PURE__ */ Rn(Cs), Es = () => (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").replace("Z", ""), z = ws.getLogger("telnyx-ai-agent"), Is = z.methodFactory;
|
|
3632
3638
|
z.methodFactory = (n, e, t) => {
|
|
3633
|
-
const i =
|
|
3639
|
+
const i = Is(n, e, t);
|
|
3634
3640
|
return function(...s) {
|
|
3635
|
-
i(
|
|
3641
|
+
i(Es(), "-", ...s);
|
|
3636
3642
|
};
|
|
3637
3643
|
};
|
|
3638
3644
|
z.setLevel("info");
|
|
3639
|
-
function
|
|
3645
|
+
function Ts(n, e) {
|
|
3640
3646
|
let t = 0;
|
|
3641
3647
|
return (...i) => {
|
|
3642
3648
|
const s = Date.now();
|
|
3643
3649
|
s - t >= e && (t = s, n(...i));
|
|
3644
3650
|
};
|
|
3645
3651
|
}
|
|
3646
|
-
const
|
|
3647
|
-
class
|
|
3652
|
+
const ks = 10, Rs = 500, As = 100, Qt = 20;
|
|
3653
|
+
class Os {
|
|
3648
3654
|
remoteIntervalId = null;
|
|
3649
3655
|
localIntervalId = null;
|
|
3650
3656
|
remoteStream = null;
|
|
@@ -3671,10 +3677,10 @@ class As {
|
|
|
3671
3677
|
minSpeechDurationMs;
|
|
3672
3678
|
maxLatencyMs;
|
|
3673
3679
|
constructor(e) {
|
|
3674
|
-
this.volumeThreshold = e?.volumeThreshold ??
|
|
3680
|
+
this.volumeThreshold = e?.volumeThreshold ?? ks, this.silenceDurationMs = e?.silenceDurationMs ?? Rs, this.minSpeechDurationMs = e?.minSpeechDurationMs ?? As, this.maxLatencyMs = e?.maxLatencyMs;
|
|
3675
3681
|
}
|
|
3676
|
-
updateAgentState =
|
|
3677
|
-
z.debug("AudioStreamMonitor updateAgentState", e), z.debug("Previous state:", this.lastState), e.state !== this.lastState && (this.lastState = e.state,
|
|
3682
|
+
updateAgentState = Ts((e) => {
|
|
3683
|
+
z.debug("AudioStreamMonitor updateAgentState", e), z.debug("Previous state:", this.lastState), e.state !== this.lastState && (this.lastState = e.state, Ke.emit("conversation.agent.state", e));
|
|
3678
3684
|
}, 100);
|
|
3679
3685
|
/**
|
|
3680
3686
|
* Set the remote audio stream (agent's voice) to monitor for speech detection
|
|
@@ -3744,7 +3750,7 @@ class As {
|
|
|
3744
3750
|
this.thinkingStartTime === null && this.updateAgentState({ state: "listening" });
|
|
3745
3751
|
i = r;
|
|
3746
3752
|
};
|
|
3747
|
-
this.remoteIntervalId = window.setInterval(s,
|
|
3753
|
+
this.remoteIntervalId = window.setInterval(s, Qt);
|
|
3748
3754
|
}
|
|
3749
3755
|
/**
|
|
3750
3756
|
* Monitor local stream (user's microphone) for VAD
|
|
@@ -3769,46 +3775,46 @@ class As {
|
|
|
3769
3775
|
this.updateAgentState({ state: "thinking", thinkingStartedAt: c });
|
|
3770
3776
|
}
|
|
3771
3777
|
};
|
|
3772
|
-
this.localIntervalId = window.setInterval(t,
|
|
3778
|
+
this.localIntervalId = window.setInterval(t, Qt);
|
|
3773
3779
|
}
|
|
3774
3780
|
destroy() {
|
|
3775
3781
|
this.stopAudioStreamMonitor();
|
|
3776
3782
|
}
|
|
3777
3783
|
}
|
|
3778
|
-
function
|
|
3784
|
+
function Ls(n) {
|
|
3779
3785
|
if (!n || typeof n != "object")
|
|
3780
3786
|
return !1;
|
|
3781
3787
|
const e = n;
|
|
3782
3788
|
return e.method === "ai_conversation" && typeof e.params == "object";
|
|
3783
3789
|
}
|
|
3784
|
-
function
|
|
3790
|
+
function Ns(n) {
|
|
3785
3791
|
if (!n || typeof n != "object")
|
|
3786
3792
|
return !1;
|
|
3787
3793
|
const e = n;
|
|
3788
3794
|
return e.params.type !== "response.text.delta" ? !1 : !!e.params.delta;
|
|
3789
3795
|
}
|
|
3790
|
-
function
|
|
3796
|
+
function xs(n) {
|
|
3791
3797
|
if (!n || typeof n != "object")
|
|
3792
3798
|
return !1;
|
|
3793
3799
|
const e = n;
|
|
3794
3800
|
return e.params.type !== "conversation.item.created" ? !1 : !!e.params.item.content;
|
|
3795
3801
|
}
|
|
3796
|
-
function
|
|
3802
|
+
function Ds(n) {
|
|
3797
3803
|
if (!n || typeof n != "object")
|
|
3798
3804
|
return !1;
|
|
3799
3805
|
const e = n;
|
|
3800
3806
|
return e.params?.type !== "conversation.item.deleted" ? !1 : !!e.params.item_id;
|
|
3801
3807
|
}
|
|
3802
|
-
function
|
|
3803
|
-
return
|
|
3808
|
+
function Ps(n) {
|
|
3809
|
+
return Ns(n) ? {
|
|
3804
3810
|
id: `${n.params.item_id}-${Date.now()}`,
|
|
3805
3811
|
role: "assistant",
|
|
3806
3812
|
content: n.params.delta,
|
|
3807
3813
|
timestamp: /* @__PURE__ */ new Date()
|
|
3808
3814
|
} : null;
|
|
3809
3815
|
}
|
|
3810
|
-
function
|
|
3811
|
-
if (!
|
|
3816
|
+
function Ms(n) {
|
|
3817
|
+
if (!xs(n) || n.params.item.role !== "user" || n.params.item.status !== "completed")
|
|
3812
3818
|
return null;
|
|
3813
3819
|
let e = "", t = [];
|
|
3814
3820
|
return Array.isArray(n.params.item.content) ? (e = n.params.item.content.reduce((i, s) => (s.type === "text" && (i += s.text), i), ""), t = n.params.item.content.reduce((i, s) => (s.type === "image_url" && s.image_url.url && i.push({ type: "image", url: s.image_url.url }), i), [])) : e = n.params.item.content, {
|
|
@@ -3819,29 +3825,29 @@ function Ps(n) {
|
|
|
3819
3825
|
attachments: t
|
|
3820
3826
|
};
|
|
3821
3827
|
}
|
|
3822
|
-
class
|
|
3828
|
+
class Us extends Ct {
|
|
3823
3829
|
telnyxRTC;
|
|
3824
3830
|
transcript = [];
|
|
3825
3831
|
constructor(e) {
|
|
3826
3832
|
super(), this.telnyxRTC = e, this.telnyxRTC.on(T.SocketMessage, this.onSocketMessage);
|
|
3827
3833
|
}
|
|
3828
3834
|
onSocketMessage = (e) => {
|
|
3829
|
-
if (
|
|
3835
|
+
if (Ls(e))
|
|
3830
3836
|
switch (e.params.type) {
|
|
3831
3837
|
case "response.text.delta": {
|
|
3832
|
-
const t =
|
|
3833
|
-
t && (this.transcript.push(t), this.emit("transcript.item", t),
|
|
3838
|
+
const t = Ps(e);
|
|
3839
|
+
t && (this.transcript.push(t), this.emit("transcript.item", t), Ke.emit("conversation.agent.state", { state: "listening" }));
|
|
3834
3840
|
return;
|
|
3835
3841
|
}
|
|
3836
3842
|
case "conversation.item.deleted": {
|
|
3837
|
-
if (
|
|
3843
|
+
if (Ds(e)) {
|
|
3838
3844
|
const t = e.params.item_id, i = this.transcript.findIndex((s) => s.id === t);
|
|
3839
3845
|
i !== -1 && this.transcript.splice(i, 1);
|
|
3840
3846
|
}
|
|
3841
3847
|
return;
|
|
3842
3848
|
}
|
|
3843
3849
|
case "conversation.item.created": {
|
|
3844
|
-
const t =
|
|
3850
|
+
const t = Ms(e);
|
|
3845
3851
|
if (t) {
|
|
3846
3852
|
const i = this.transcript.findIndex(
|
|
3847
3853
|
(s) => s.id === t.id
|
|
@@ -3853,7 +3859,7 @@ class Ms extends Ct {
|
|
|
3853
3859
|
}
|
|
3854
3860
|
};
|
|
3855
3861
|
}
|
|
3856
|
-
class
|
|
3862
|
+
class Xt extends Ct {
|
|
3857
3863
|
telnyxRTC;
|
|
3858
3864
|
transcription;
|
|
3859
3865
|
agentId;
|
|
@@ -3896,16 +3902,16 @@ class Qt extends Ct {
|
|
|
3896
3902
|
};
|
|
3897
3903
|
e.conversationId && (t.target_params = {
|
|
3898
3904
|
conversation_id: e.conversationId
|
|
3899
|
-
}), this.telnyxRTC = new
|
|
3905
|
+
}), this.telnyxRTC = new ms({
|
|
3900
3906
|
env: e.environment || "production",
|
|
3901
3907
|
anonymous_login: t,
|
|
3902
3908
|
debug: e.debug || !1,
|
|
3903
3909
|
trickleIce: e.trickleIce,
|
|
3904
3910
|
region: e.region
|
|
3905
|
-
}), this.telnyxRTC.on(T.Ready, this.onClientReady), this.telnyxRTC.on(T.Error, this.onClientOrSocketError), this.telnyxRTC.on(T.SocketError, this.onClientOrSocketError), this.telnyxRTC.on(T.Notification, this.onNotification), this.transcription = new
|
|
3911
|
+
}), this.telnyxRTC.on(T.Ready, this.onClientReady), this.telnyxRTC.on(T.Error, this.onClientOrSocketError), this.telnyxRTC.on(T.SocketError, this.onClientOrSocketError), this.telnyxRTC.on(T.Notification, this.onNotification), this.transcription = new Us(this.telnyxRTC), this.transcription.addListener("transcript.item", this.onTranscriptItem), Ke.addListener(
|
|
3906
3912
|
"conversation.agent.state",
|
|
3907
3913
|
this.onAgentStateChange
|
|
3908
|
-
), this.audioStreamMonitor = new
|
|
3914
|
+
), this.audioStreamMonitor = new Os(e.vad);
|
|
3909
3915
|
}
|
|
3910
3916
|
/**
|
|
3911
3917
|
* Connects to the Telnyx WebRTC service and establishes a session with the AI agent.
|
|
@@ -3930,7 +3936,7 @@ class Qt extends Ct {
|
|
|
3930
3936
|
* Emits an 'agent.disconnected' event before completing cleanup.
|
|
3931
3937
|
*/
|
|
3932
3938
|
async disconnect() {
|
|
3933
|
-
this.audioStreamMonitor.destroy(), this.telnyxRTC.disconnect(), this.telnyxRTC.off(T.Ready, this.onClientReady), this.telnyxRTC.off(T.Error, this.onClientOrSocketError), this.telnyxRTC.off(T.SocketError, this.onClientOrSocketError), this.telnyxRTC.off(T.Notification, this.onNotification), this.dc = null, this.region = null, this.callReportId = null, this.emit("agent.disconnected"), this.transcription.removeAllListeners(),
|
|
3939
|
+
this.audioStreamMonitor.destroy(), this.telnyxRTC.disconnect(), this.telnyxRTC.off(T.Ready, this.onClientReady), this.telnyxRTC.off(T.Error, this.onClientOrSocketError), this.telnyxRTC.off(T.SocketError, this.onClientOrSocketError), this.telnyxRTC.off(T.Notification, this.onNotification), this.dc = null, this.region = null, this.callReportId = null, this.emit("agent.disconnected"), this.transcription.removeAllListeners(), Ke.removeAllListeners(), this.removeAllListeners();
|
|
3934
3940
|
}
|
|
3935
3941
|
/**
|
|
3936
3942
|
* Sends a text message to the AI agent during an active conversation.
|
|
@@ -4057,7 +4063,7 @@ class Qt extends Ct {
|
|
|
4057
4063
|
}
|
|
4058
4064
|
var Be = { exports: {} }, Ce = {};
|
|
4059
4065
|
var Zt;
|
|
4060
|
-
function
|
|
4066
|
+
function Fs() {
|
|
4061
4067
|
if (Zt) return Ce;
|
|
4062
4068
|
Zt = 1;
|
|
4063
4069
|
var n = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
|
|
@@ -4080,7 +4086,7 @@ function Us() {
|
|
|
4080
4086
|
}
|
|
4081
4087
|
var we = {};
|
|
4082
4088
|
var en;
|
|
4083
|
-
function
|
|
4089
|
+
function js() {
|
|
4084
4090
|
return en || (en = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
4085
4091
|
function n(C) {
|
|
4086
4092
|
if (C == null) return null;
|
|
@@ -4188,7 +4194,7 @@ function Fs() {
|
|
|
4188
4194
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
4189
4195
|
)), C = this.props.ref, C !== void 0 ? C : null;
|
|
4190
4196
|
}
|
|
4191
|
-
function l(C, D, j, H,
|
|
4197
|
+
function l(C, D, j, H, K, X) {
|
|
4192
4198
|
var V = j.ref;
|
|
4193
4199
|
return C = {
|
|
4194
4200
|
$$typeof: v,
|
|
@@ -4213,15 +4219,15 @@ function Fs() {
|
|
|
4213
4219
|
configurable: !1,
|
|
4214
4220
|
enumerable: !1,
|
|
4215
4221
|
writable: !0,
|
|
4216
|
-
value:
|
|
4222
|
+
value: K
|
|
4217
4223
|
}), Object.defineProperty(C, "_debugTask", {
|
|
4218
4224
|
configurable: !1,
|
|
4219
4225
|
enumerable: !1,
|
|
4220
4226
|
writable: !0,
|
|
4221
|
-
value:
|
|
4227
|
+
value: X
|
|
4222
4228
|
}), Object.freeze && (Object.freeze(C.props), Object.freeze(C)), C;
|
|
4223
4229
|
}
|
|
4224
|
-
function f(C, D, j, H,
|
|
4230
|
+
function f(C, D, j, H, K, X) {
|
|
4225
4231
|
var V = D.children;
|
|
4226
4232
|
if (V !== void 0)
|
|
4227
4233
|
if (H)
|
|
@@ -4236,8 +4242,8 @@ function Fs() {
|
|
|
4236
4242
|
else h(V);
|
|
4237
4243
|
if (b.call(D, "key")) {
|
|
4238
4244
|
V = n(C);
|
|
4239
|
-
var ae = Object.keys(D).filter(function(
|
|
4240
|
-
return
|
|
4245
|
+
var ae = Object.keys(D).filter(function(Wn) {
|
|
4246
|
+
return Wn !== "key";
|
|
4241
4247
|
});
|
|
4242
4248
|
H = 0 < ae.length ? "{key: someKey, " + ae.join(": ..., ") + ": ...}" : "{key: someKey}", G[V + H] || (ae = 0 < ae.length ? "{" + ae.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
4243
4249
|
`A props object containing a "key" prop is being spread into JSX:
|
|
@@ -4265,8 +4271,8 @@ React keys must be passed directly to JSX without using spread:
|
|
|
4265
4271
|
V,
|
|
4266
4272
|
j,
|
|
4267
4273
|
s(),
|
|
4268
|
-
|
|
4269
|
-
|
|
4274
|
+
K,
|
|
4275
|
+
X
|
|
4270
4276
|
);
|
|
4271
4277
|
}
|
|
4272
4278
|
function h(C) {
|
|
@@ -4311,12 +4317,12 @@ React keys must be passed directly to JSX without using spread:
|
|
|
4311
4317
|
})()), we;
|
|
4312
4318
|
}
|
|
4313
4319
|
var tn;
|
|
4314
|
-
function
|
|
4315
|
-
return tn || (tn = 1, process.env.NODE_ENV === "production" ? Be.exports =
|
|
4320
|
+
function Bs() {
|
|
4321
|
+
return tn || (tn = 1, process.env.NODE_ENV === "production" ? Be.exports = Fs() : Be.exports = js()), Be.exports;
|
|
4316
4322
|
}
|
|
4317
|
-
var Ee =
|
|
4323
|
+
var Ee = Bs();
|
|
4318
4324
|
const de = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 };
|
|
4319
|
-
function
|
|
4325
|
+
function An(n) {
|
|
4320
4326
|
return "init" in n;
|
|
4321
4327
|
}
|
|
4322
4328
|
function pt(n) {
|
|
@@ -4332,19 +4338,19 @@ function ze(n) {
|
|
|
4332
4338
|
throw new Error("[Bug] atom state is not initialized");
|
|
4333
4339
|
return n.v;
|
|
4334
4340
|
}
|
|
4335
|
-
const
|
|
4336
|
-
function
|
|
4341
|
+
const Qe = /* @__PURE__ */ new WeakMap();
|
|
4342
|
+
function On(n) {
|
|
4337
4343
|
var e;
|
|
4338
|
-
return
|
|
4344
|
+
return Xe(n) && !!((e = Qe.get(n)) != null && e[0]);
|
|
4339
4345
|
}
|
|
4340
|
-
function
|
|
4341
|
-
const e =
|
|
4346
|
+
function $s(n) {
|
|
4347
|
+
const e = Qe.get(n);
|
|
4342
4348
|
e?.[0] && (e[0] = !1, e[1].forEach((t) => t()));
|
|
4343
4349
|
}
|
|
4344
4350
|
function ft(n, e) {
|
|
4345
|
-
let t =
|
|
4351
|
+
let t = Qe.get(n);
|
|
4346
4352
|
if (!t) {
|
|
4347
|
-
t = [!0, /* @__PURE__ */ new Set()],
|
|
4353
|
+
t = [!0, /* @__PURE__ */ new Set()], Qe.set(n, t);
|
|
4348
4354
|
const i = () => {
|
|
4349
4355
|
t[0] = !1;
|
|
4350
4356
|
};
|
|
@@ -4352,17 +4358,17 @@ function ft(n, e) {
|
|
|
4352
4358
|
}
|
|
4353
4359
|
t[1].add(e);
|
|
4354
4360
|
}
|
|
4355
|
-
function
|
|
4361
|
+
function Xe(n) {
|
|
4356
4362
|
return typeof n?.then == "function";
|
|
4357
4363
|
}
|
|
4358
|
-
function
|
|
4364
|
+
function Ln(n, e, t) {
|
|
4359
4365
|
if (!t.p.has(n)) {
|
|
4360
4366
|
t.p.add(n);
|
|
4361
4367
|
const i = () => t.p.delete(n);
|
|
4362
4368
|
e.then(i, i);
|
|
4363
4369
|
}
|
|
4364
4370
|
}
|
|
4365
|
-
function
|
|
4371
|
+
function Nn(n, e, t) {
|
|
4366
4372
|
var i;
|
|
4367
4373
|
const s = /* @__PURE__ */ new Set();
|
|
4368
4374
|
for (const o of ((i = t.get(n)) == null ? void 0 : i.t) || [])
|
|
@@ -4371,24 +4377,24 @@ function Ln(n, e, t) {
|
|
|
4371
4377
|
s.add(o);
|
|
4372
4378
|
return s;
|
|
4373
4379
|
}
|
|
4374
|
-
const
|
|
4380
|
+
const Hs = (n, e, ...t) => e.read(...t), Ws = (n, e, ...t) => e.write(...t), Gs = (n, e) => {
|
|
4375
4381
|
if (e.INTERNAL_onInit)
|
|
4376
4382
|
return e.INTERNAL_onInit(n);
|
|
4377
4383
|
if (e.unstable_onInit)
|
|
4378
4384
|
return console.warn(
|
|
4379
4385
|
"[DEPRECATED] atom.unstable_onInit is renamed to atom.INTERNAL_onInit."
|
|
4380
4386
|
), e.unstable_onInit(n);
|
|
4381
|
-
},
|
|
4387
|
+
}, Vs = (n, e, t) => {
|
|
4382
4388
|
var i;
|
|
4383
4389
|
return (i = e.onMount) == null ? void 0 : i.call(e, t);
|
|
4384
|
-
},
|
|
4390
|
+
}, qs = (n, e) => {
|
|
4385
4391
|
var t;
|
|
4386
4392
|
const i = Z(n), s = i[0], o = i[6], r = i[9];
|
|
4387
4393
|
if ((de ? "production" : void 0) !== "production" && !e)
|
|
4388
4394
|
throw new Error("Atom is undefined or null");
|
|
4389
4395
|
let c = s.get(e);
|
|
4390
4396
|
return c || (c = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, s.set(e, c), (t = o.i) == null || t.call(o, e), r?.(n, e)), c;
|
|
4391
|
-
},
|
|
4397
|
+
}, Ys = (n) => {
|
|
4392
4398
|
const e = Z(n), t = e[1], i = e[3], s = e[4], o = e[5], r = e[6], c = e[13], u = [], l = (f) => {
|
|
4393
4399
|
try {
|
|
4394
4400
|
f();
|
|
@@ -4406,7 +4412,7 @@ const $s = (n, e, ...t) => e.read(...t), Hs = (n, e, ...t) => e.write(...t), Ws
|
|
|
4406
4412
|
} while (i.size || o.size || s.size);
|
|
4407
4413
|
if (u.length)
|
|
4408
4414
|
throw new AggregateError(u);
|
|
4409
|
-
},
|
|
4415
|
+
}, Js = (n) => {
|
|
4410
4416
|
const e = Z(n), t = e[1], i = e[2], s = e[3], o = e[11], r = e[14], c = e[17], u = [], l = /* @__PURE__ */ new WeakSet(), f = /* @__PURE__ */ new WeakSet(), h = Array.from(s);
|
|
4411
4417
|
for (; h.length; ) {
|
|
4412
4418
|
const S = h[h.length - 1], y = o(n, S);
|
|
@@ -4423,7 +4429,7 @@ const $s = (n, e, ...t) => e.read(...t), Hs = (n, e, ...t) => e.write(...t), Ws
|
|
|
4423
4429
|
continue;
|
|
4424
4430
|
}
|
|
4425
4431
|
l.add(S);
|
|
4426
|
-
for (const v of
|
|
4432
|
+
for (const v of Nn(S, y, t))
|
|
4427
4433
|
l.has(v) || h.push(v);
|
|
4428
4434
|
}
|
|
4429
4435
|
for (let S = u.length - 1; S >= 0; --S) {
|
|
@@ -4461,7 +4467,7 @@ const $s = (n, e, ...t) => e.read(...t), Hs = (n, e, ...t) => e.write(...t), Ws
|
|
|
4461
4467
|
if (R === e) {
|
|
4462
4468
|
const p = f(n, R);
|
|
4463
4469
|
if (!nn(p))
|
|
4464
|
-
if (
|
|
4470
|
+
if (An(R))
|
|
4465
4471
|
Ze(n, R, R.init);
|
|
4466
4472
|
else
|
|
4467
4473
|
throw new Error("no atom init");
|
|
@@ -4471,7 +4477,7 @@ const $s = (n, e, ...t) => e.read(...t), Hs = (n, e, ...t) => e.write(...t), Ws
|
|
|
4471
4477
|
try {
|
|
4472
4478
|
return ze(d);
|
|
4473
4479
|
} finally {
|
|
4474
|
-
m.d.set(R, d.n),
|
|
4480
|
+
m.d.set(R, d.n), On(m.v) && Ln(e, m.v, d), o.has(e) && ((a = o.get(R)) == null || a.t.add(e)), w || N();
|
|
4475
4481
|
}
|
|
4476
4482
|
}
|
|
4477
4483
|
let P, M;
|
|
@@ -4495,22 +4501,22 @@ const $s = (n, e, ...t) => e.read(...t), Hs = (n, e, ...t) => e.write(...t), Ws
|
|
|
4495
4501
|
const R = l(n, e, A, q);
|
|
4496
4502
|
return (de ? "production" : void 0) !== "production" && gt.has(n) && console.warn(
|
|
4497
4503
|
"Detected store mutation during atom read. This is not supported."
|
|
4498
|
-
), Ze(n, e, R),
|
|
4504
|
+
), Ze(n, e, R), Xe(R) && (ft(R, () => P?.abort()), R.then(N, N)), (t = u.r) == null || t.call(u, e), m;
|
|
4499
4505
|
} catch (R) {
|
|
4500
4506
|
return delete m.v, m.e = R, ++m.n, m;
|
|
4501
4507
|
} finally {
|
|
4502
4508
|
w = !1, F !== m.n && r.get(e) === F && (r.set(e, m.n), c.add(e), (i = u.c) == null || i.call(u, e));
|
|
4503
4509
|
}
|
|
4504
|
-
},
|
|
4510
|
+
}, zs = (n, e) => {
|
|
4505
4511
|
const t = Z(n), i = t[1], s = t[2], o = t[11], r = [e];
|
|
4506
4512
|
for (; r.length; ) {
|
|
4507
4513
|
const c = r.pop(), u = o(n, c);
|
|
4508
|
-
for (const l of
|
|
4514
|
+
for (const l of Nn(c, u, i)) {
|
|
4509
4515
|
const f = o(n, l);
|
|
4510
4516
|
s.set(l, f.n), r.push(l);
|
|
4511
4517
|
}
|
|
4512
4518
|
}
|
|
4513
|
-
},
|
|
4519
|
+
}, xn = (n, e, ...t) => {
|
|
4514
4520
|
const i = Z(n), s = i[3], o = i[6], r = i[8], c = i[11], u = i[12], l = i[13], f = i[14], h = i[15], S = i[17];
|
|
4515
4521
|
let y = !0;
|
|
4516
4522
|
const v = (m) => ze(f(n, m)), E = (m, ...w) => {
|
|
@@ -4518,14 +4524,14 @@ const $s = (n, e, ...t) => e.read(...t), Hs = (n, e, ...t) => e.write(...t), Ws
|
|
|
4518
4524
|
const A = c(n, m);
|
|
4519
4525
|
try {
|
|
4520
4526
|
if (m === e) {
|
|
4521
|
-
if (!
|
|
4527
|
+
if (!An(m))
|
|
4522
4528
|
throw new Error("atom not writable");
|
|
4523
4529
|
(de ? "production" : void 0) !== "production" && gt.add(n);
|
|
4524
4530
|
const P = A.n, M = w[0];
|
|
4525
4531
|
Ze(n, m, M), S(n, m), P !== A.n && (s.add(m), h(n, m), (N = o.c) == null || N.call(o, m));
|
|
4526
4532
|
return;
|
|
4527
4533
|
} else
|
|
4528
|
-
return
|
|
4534
|
+
return xn(n, m, ...w);
|
|
4529
4535
|
} finally {
|
|
4530
4536
|
y || (l(n), u(n));
|
|
4531
4537
|
}
|
|
@@ -4535,10 +4541,10 @@ const $s = (n, e, ...t) => e.read(...t), Hs = (n, e, ...t) => e.write(...t), Ws
|
|
|
4535
4541
|
} finally {
|
|
4536
4542
|
y = !1;
|
|
4537
4543
|
}
|
|
4538
|
-
},
|
|
4544
|
+
}, Qs = (n, e) => {
|
|
4539
4545
|
var t;
|
|
4540
4546
|
const i = Z(n), s = i[1], o = i[3], r = i[6], c = i[11], u = i[15], l = i[18], f = i[19], h = c(n, e), S = s.get(e);
|
|
4541
|
-
if (S && !
|
|
4547
|
+
if (S && !On(h.v)) {
|
|
4542
4548
|
for (const [y, v] of h.d)
|
|
4543
4549
|
if (!S.d.has(y)) {
|
|
4544
4550
|
const E = c(n, y);
|
|
@@ -4551,14 +4557,14 @@ const $s = (n, e, ...t) => e.read(...t), Hs = (n, e, ...t) => e.write(...t), Ws
|
|
|
4551
4557
|
v?.t.delete(e);
|
|
4552
4558
|
}
|
|
4553
4559
|
}
|
|
4554
|
-
},
|
|
4560
|
+
}, Dn = (n, e) => {
|
|
4555
4561
|
var t;
|
|
4556
4562
|
const i = Z(n), s = i[1], o = i[4], r = i[6], c = i[10], u = i[11], l = i[12], f = i[13], h = i[14], S = i[16], y = u(n, e);
|
|
4557
4563
|
let v = s.get(e);
|
|
4558
4564
|
if (!v) {
|
|
4559
4565
|
h(n, e);
|
|
4560
4566
|
for (const E of y.d.keys())
|
|
4561
|
-
|
|
4567
|
+
Dn(n, E).t.add(e);
|
|
4562
4568
|
if (v = {
|
|
4563
4569
|
l: /* @__PURE__ */ new Set(),
|
|
4564
4570
|
d: new Set(y.d.keys()),
|
|
@@ -4616,38 +4622,38 @@ const $s = (n, e, ...t) => e.read(...t), Hs = (n, e, ...t) => e.write(...t), Ws
|
|
|
4616
4622
|
return h;
|
|
4617
4623
|
}, Ze = (n, e, t) => {
|
|
4618
4624
|
const i = Z(n)[11], s = i(n, e), o = "v" in s, r = s.v;
|
|
4619
|
-
if (
|
|
4625
|
+
if (Xe(t))
|
|
4620
4626
|
for (const c of s.d.keys())
|
|
4621
|
-
|
|
4627
|
+
Ln(
|
|
4622
4628
|
e,
|
|
4623
4629
|
t,
|
|
4624
4630
|
i(n, c)
|
|
4625
4631
|
);
|
|
4626
|
-
s.v = t, delete s.e, (!o || !Object.is(r, s.v)) && (++s.n,
|
|
4627
|
-
},
|
|
4632
|
+
s.v = t, delete s.e, (!o || !Object.is(r, s.v)) && (++s.n, Xe(r) && $s(r));
|
|
4633
|
+
}, Zs = (n, e) => {
|
|
4628
4634
|
const t = Z(n)[14];
|
|
4629
4635
|
return ze(t(n, e));
|
|
4630
|
-
},
|
|
4636
|
+
}, eo = (n, e, ...t) => {
|
|
4631
4637
|
const i = Z(n), s = i[12], o = i[13], r = i[16];
|
|
4632
4638
|
try {
|
|
4633
4639
|
return r(n, e, ...t);
|
|
4634
4640
|
} finally {
|
|
4635
4641
|
o(n), s(n);
|
|
4636
4642
|
}
|
|
4637
|
-
},
|
|
4643
|
+
}, to = (n, e, t) => {
|
|
4638
4644
|
const i = Z(n), s = i[12], o = i[18], r = i[19], u = o(n, e).l;
|
|
4639
4645
|
return u.add(t), s(n), () => {
|
|
4640
4646
|
u.delete(t), r(n, e), s(n);
|
|
4641
4647
|
};
|
|
4642
|
-
},
|
|
4643
|
-
const e =
|
|
4648
|
+
}, Pn = /* @__PURE__ */ new WeakMap(), Z = (n) => {
|
|
4649
|
+
const e = Pn.get(n);
|
|
4644
4650
|
if ((de ? "production" : void 0) !== "production" && !e)
|
|
4645
4651
|
throw new Error(
|
|
4646
4652
|
"Store must be created by buildStore to read its building blocks"
|
|
4647
4653
|
);
|
|
4648
4654
|
return e;
|
|
4649
4655
|
};
|
|
4650
|
-
function
|
|
4656
|
+
function no(...n) {
|
|
4651
4657
|
const e = {
|
|
4652
4658
|
get(i) {
|
|
4653
4659
|
const s = Z(e)[21];
|
|
@@ -4678,61 +4684,61 @@ function to(...n) {
|
|
|
4678
4684
|
{},
|
|
4679
4685
|
// storeHooks
|
|
4680
4686
|
// atom interceptors
|
|
4681
|
-
$s,
|
|
4682
4687
|
Hs,
|
|
4683
4688
|
Ws,
|
|
4684
4689
|
Gs,
|
|
4685
|
-
// building-block functions
|
|
4686
4690
|
Vs,
|
|
4691
|
+
// building-block functions
|
|
4687
4692
|
qs,
|
|
4688
4693
|
Ys,
|
|
4689
|
-
Ks,
|
|
4690
4694
|
Js,
|
|
4691
|
-
|
|
4695
|
+
Ks,
|
|
4692
4696
|
zs,
|
|
4693
4697
|
xn,
|
|
4698
|
+
Qs,
|
|
4699
|
+
Dn,
|
|
4694
4700
|
Xs,
|
|
4695
4701
|
Ze,
|
|
4696
|
-
Qs,
|
|
4697
4702
|
Zs,
|
|
4698
4703
|
eo,
|
|
4704
|
+
to,
|
|
4699
4705
|
void 0
|
|
4700
4706
|
].map((i, s) => n[s] || i);
|
|
4701
|
-
return
|
|
4707
|
+
return Pn.set(e, Object.freeze(t)), e;
|
|
4702
4708
|
}
|
|
4703
|
-
const
|
|
4704
|
-
let
|
|
4709
|
+
const Mn = {};
|
|
4710
|
+
let io = 0;
|
|
4705
4711
|
function et(n, e) {
|
|
4706
|
-
const t = `atom${++
|
|
4712
|
+
const t = `atom${++io}`, i = {
|
|
4707
4713
|
toString() {
|
|
4708
|
-
return (
|
|
4714
|
+
return (Mn ? "production" : void 0) !== "production" && this.debugLabel ? t + ":" + this.debugLabel : t;
|
|
4709
4715
|
}
|
|
4710
4716
|
};
|
|
4711
|
-
return typeof n == "function" ? i.read = n : (i.init = n, i.read =
|
|
4717
|
+
return typeof n == "function" ? i.read = n : (i.init = n, i.read = so, i.write = oo), i;
|
|
4712
4718
|
}
|
|
4713
|
-
function
|
|
4719
|
+
function so(n) {
|
|
4714
4720
|
return n(this);
|
|
4715
4721
|
}
|
|
4716
|
-
function
|
|
4722
|
+
function oo(n, e, t) {
|
|
4717
4723
|
return e(
|
|
4718
4724
|
this,
|
|
4719
4725
|
typeof t == "function" ? t(n(this)) : t
|
|
4720
4726
|
);
|
|
4721
4727
|
}
|
|
4722
|
-
function
|
|
4723
|
-
return
|
|
4728
|
+
function ro() {
|
|
4729
|
+
return no();
|
|
4724
4730
|
}
|
|
4725
4731
|
let Ie;
|
|
4726
|
-
function
|
|
4727
|
-
return Ie || (Ie =
|
|
4732
|
+
function ao() {
|
|
4733
|
+
return Ie || (Ie = ro(), (Mn ? "production" : void 0) !== "production" && (globalThis.__JOTAI_DEFAULT_STORE__ || (globalThis.__JOTAI_DEFAULT_STORE__ = Ie), globalThis.__JOTAI_DEFAULT_STORE__ !== Ie && console.warn(
|
|
4728
4734
|
"Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"
|
|
4729
4735
|
))), Ie;
|
|
4730
4736
|
}
|
|
4731
|
-
const
|
|
4737
|
+
const co = {}, lo = rn(
|
|
4732
4738
|
void 0
|
|
4733
4739
|
);
|
|
4734
|
-
function
|
|
4735
|
-
return on(
|
|
4740
|
+
function Un(n) {
|
|
4741
|
+
return on(lo) || ao();
|
|
4736
4742
|
}
|
|
4737
4743
|
const vt = (n) => typeof n?.then == "function", mt = (n) => {
|
|
4738
4744
|
n.status || (n.status = "pending", n.then(
|
|
@@ -4743,7 +4749,7 @@ const vt = (n) => typeof n?.then == "function", mt = (n) => {
|
|
|
4743
4749
|
n.status = "rejected", n.reason = e;
|
|
4744
4750
|
}
|
|
4745
4751
|
));
|
|
4746
|
-
},
|
|
4752
|
+
}, uo = _t.use || // A shim for older React versions
|
|
4747
4753
|
((n) => {
|
|
4748
4754
|
if (n.status === "pending")
|
|
4749
4755
|
throw n;
|
|
@@ -4770,7 +4776,7 @@ const vt = (n) => typeof n?.then == "function", mt = (n) => {
|
|
|
4770
4776
|
}), ct.set(n, t)), t;
|
|
4771
4777
|
};
|
|
4772
4778
|
function tt(n, e) {
|
|
4773
|
-
const { delay: t, unstable_promiseStatus: i = !_t.use } = {}, s =
|
|
4779
|
+
const { delay: t, unstable_promiseStatus: i = !_t.use } = {}, s = Un(), [[o, r, c], u] = Gn(
|
|
4774
4780
|
(f) => {
|
|
4775
4781
|
const h = s.get(n);
|
|
4776
4782
|
return Object.is(f[0], h) && f[1] === s && f[2] === n ? f : [h, s, n];
|
|
@@ -4796,38 +4802,38 @@ function tt(n, e) {
|
|
|
4796
4802
|
u();
|
|
4797
4803
|
});
|
|
4798
4804
|
return u(), f;
|
|
4799
|
-
}, [s, n, t, i]),
|
|
4805
|
+
}, [s, n, t, i]), Vn(l), vt(l)) {
|
|
4800
4806
|
const f = sn(l, () => s.get(n));
|
|
4801
|
-
return i && mt(f),
|
|
4807
|
+
return i && mt(f), uo(f);
|
|
4802
4808
|
}
|
|
4803
4809
|
return l;
|
|
4804
4810
|
}
|
|
4805
4811
|
function nt(n, e) {
|
|
4806
|
-
const t =
|
|
4807
|
-
return
|
|
4812
|
+
const t = Un();
|
|
4813
|
+
return qn(
|
|
4808
4814
|
(...s) => {
|
|
4809
|
-
if ((
|
|
4815
|
+
if ((co ? "production" : void 0) !== "production" && !("write" in n))
|
|
4810
4816
|
throw new Error("not writable atom");
|
|
4811
4817
|
return t.set(n, ...s);
|
|
4812
4818
|
},
|
|
4813
4819
|
[t, n]
|
|
4814
4820
|
);
|
|
4815
4821
|
}
|
|
4816
|
-
const
|
|
4817
|
-
function
|
|
4818
|
-
return tt(
|
|
4822
|
+
const Fn = et([]);
|
|
4823
|
+
function bo() {
|
|
4824
|
+
return tt(Fn);
|
|
4819
4825
|
}
|
|
4820
|
-
function
|
|
4821
|
-
return nt(
|
|
4826
|
+
function ho() {
|
|
4827
|
+
return nt(Fn);
|
|
4822
4828
|
}
|
|
4823
4829
|
const it = () => {
|
|
4824
|
-
const n = on(
|
|
4830
|
+
const n = on(Hn);
|
|
4825
4831
|
if (!n)
|
|
4826
4832
|
throw new Error("useClient must be used within a TelnyxAIAgentProvider");
|
|
4827
4833
|
return n;
|
|
4828
4834
|
};
|
|
4829
|
-
function
|
|
4830
|
-
const n = it(), e =
|
|
4835
|
+
function po() {
|
|
4836
|
+
const n = it(), e = ho();
|
|
4831
4837
|
return ve(() => {
|
|
4832
4838
|
const t = (i) => e((s) => [...s, i]);
|
|
4833
4839
|
return n.addListener("transcript.item", t), () => {
|
|
@@ -4835,15 +4841,15 @@ function ho() {
|
|
|
4835
4841
|
};
|
|
4836
4842
|
}, [n, e]), null;
|
|
4837
4843
|
}
|
|
4838
|
-
const
|
|
4839
|
-
function
|
|
4840
|
-
return tt(
|
|
4841
|
-
}
|
|
4842
|
-
function po() {
|
|
4843
|
-
return nt(Fn);
|
|
4844
|
+
const jn = et("connecting");
|
|
4845
|
+
function Co() {
|
|
4846
|
+
return tt(jn);
|
|
4844
4847
|
}
|
|
4845
4848
|
function fo() {
|
|
4846
|
-
|
|
4849
|
+
return nt(jn);
|
|
4850
|
+
}
|
|
4851
|
+
function go() {
|
|
4852
|
+
const n = it(), e = fo();
|
|
4847
4853
|
return ve(() => {
|
|
4848
4854
|
const t = () => e("connected"), i = () => e("disconnected"), s = () => e("error");
|
|
4849
4855
|
return n.addListener("agent.connected", t), n.addListener("agent.disconnected", i), n.addListener("agent.error", s), () => {
|
|
@@ -4851,15 +4857,15 @@ function fo() {
|
|
|
4851
4857
|
};
|
|
4852
4858
|
}, [n, e]), null;
|
|
4853
4859
|
}
|
|
4854
|
-
const
|
|
4855
|
-
function
|
|
4856
|
-
return tt(
|
|
4860
|
+
const Bn = et(null);
|
|
4861
|
+
function wo() {
|
|
4862
|
+
return tt(Bn);
|
|
4857
4863
|
}
|
|
4858
|
-
function
|
|
4859
|
-
return nt(
|
|
4864
|
+
function vo() {
|
|
4865
|
+
return nt(Bn);
|
|
4860
4866
|
}
|
|
4861
|
-
const
|
|
4862
|
-
const n = it(), e =
|
|
4867
|
+
const mo = () => {
|
|
4868
|
+
const n = it(), e = vo();
|
|
4863
4869
|
return ve(() => {
|
|
4864
4870
|
const t = (i) => {
|
|
4865
4871
|
e(i);
|
|
@@ -4868,15 +4874,15 @@ const vo = () => {
|
|
|
4868
4874
|
n.removeListener("conversation.update", t);
|
|
4869
4875
|
};
|
|
4870
4876
|
}, [n, e]), null;
|
|
4871
|
-
},
|
|
4872
|
-
function
|
|
4873
|
-
return tt(
|
|
4874
|
-
}
|
|
4875
|
-
function mo() {
|
|
4876
|
-
return nt(Bn);
|
|
4877
|
+
}, $n = et({ state: "listening" });
|
|
4878
|
+
function Eo() {
|
|
4879
|
+
return tt($n);
|
|
4877
4880
|
}
|
|
4878
4881
|
function _o() {
|
|
4879
|
-
|
|
4882
|
+
return nt($n);
|
|
4883
|
+
}
|
|
4884
|
+
function yo() {
|
|
4885
|
+
const n = it(), e = _o();
|
|
4880
4886
|
return ve(() => {
|
|
4881
4887
|
const t = (i) => {
|
|
4882
4888
|
e(i);
|
|
@@ -4886,7 +4892,7 @@ function _o() {
|
|
|
4886
4892
|
};
|
|
4887
4893
|
}, [n, e]), null;
|
|
4888
4894
|
}
|
|
4889
|
-
const
|
|
4895
|
+
const Hn = rn(null), Io = ({
|
|
4890
4896
|
children: n,
|
|
4891
4897
|
agentId: e,
|
|
4892
4898
|
environment: t,
|
|
@@ -4894,36 +4900,36 @@ const $n = rn(null), Eo = ({
|
|
|
4894
4900
|
debug: s,
|
|
4895
4901
|
vad: o
|
|
4896
4902
|
}) => {
|
|
4897
|
-
const [r, c] =
|
|
4903
|
+
const [r, c] = Yn(() => new Xt({ agentId: e, environment: t, versionId: i, debug: s, vad: o }));
|
|
4898
4904
|
return ve(() => {
|
|
4899
4905
|
if (!r) {
|
|
4900
|
-
const u = new
|
|
4906
|
+
const u = new Xt({ agentId: e, environment: t, versionId: i, vad: o });
|
|
4901
4907
|
return c(u), () => {
|
|
4902
4908
|
u.disconnect();
|
|
4903
4909
|
};
|
|
4904
4910
|
}
|
|
4905
4911
|
}, [e, r, t, i, o]), ve(() => {
|
|
4906
4912
|
r?.connect();
|
|
4907
|
-
}, [r]), /* @__PURE__ */ Ee.jsxs(
|
|
4908
|
-
/* @__PURE__ */ Ee.jsx(
|
|
4909
|
-
/* @__PURE__ */ Ee.jsx(
|
|
4910
|
-
/* @__PURE__ */ Ee.jsx(
|
|
4911
|
-
/* @__PURE__ */ Ee.jsx(
|
|
4913
|
+
}, [r]), /* @__PURE__ */ Ee.jsxs(Hn.Provider, { value: r, children: [
|
|
4914
|
+
/* @__PURE__ */ Ee.jsx(po, {}),
|
|
4915
|
+
/* @__PURE__ */ Ee.jsx(go, {}),
|
|
4916
|
+
/* @__PURE__ */ Ee.jsx(mo, {}),
|
|
4917
|
+
/* @__PURE__ */ Ee.jsx(yo, {}),
|
|
4912
4918
|
n
|
|
4913
4919
|
] });
|
|
4914
4920
|
};
|
|
4915
4921
|
export {
|
|
4916
|
-
|
|
4922
|
+
Hn as ClientContext,
|
|
4917
4923
|
T as SwEvent,
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4924
|
+
Xt as TelnyxAIAgent,
|
|
4925
|
+
Io as TelnyxAIAgentProvider,
|
|
4926
|
+
Eo as useAgentState,
|
|
4921
4927
|
it as useClient,
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4928
|
+
Co as useConnectionState,
|
|
4929
|
+
wo as useConversation,
|
|
4930
|
+
_o as useSetAgentState,
|
|
4931
|
+
fo as useSetConnectionState,
|
|
4932
|
+
vo as useSetConversation,
|
|
4933
|
+
ho as useSetTranscript,
|
|
4934
|
+
bo as useTranscript
|
|
4929
4935
|
};
|