@telnyx/ai-agent-lib 0.3.1 → 0.3.2-beta.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/client.d.ts +20 -0
- package/dist/index.js +29 -2
- package/dist/types.d.ts +23 -1
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -41,6 +41,26 @@ export declare class TelnyxAIAgent extends EventEmitter<AIAgentEvents> {
|
|
|
41
41
|
* Audio is negotiated as recvonly so agent speech can still be received.
|
|
42
42
|
*/
|
|
43
43
|
chatMode: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Datacenter identifier captured from the REGED message (e.g. `"ams3-prod"`).
|
|
46
|
+
* Populated right before `agent.connected` is emitted. `null` until the
|
|
47
|
+
* session registers, and always `null` on SDK versions that pre-date
|
|
48
|
+
* team-telnyx/webrtc#583.
|
|
49
|
+
*/
|
|
50
|
+
dc: string | null;
|
|
51
|
+
/**
|
|
52
|
+
* Region identifier captured from the REGED message (e.g. `"eu-west"`).
|
|
53
|
+
* Populated right before `agent.connected` is emitted. `null` until the
|
|
54
|
+
* session registers, and always `null` on SDK versions that pre-date
|
|
55
|
+
* team-telnyx/webrtc#583.
|
|
56
|
+
*/
|
|
57
|
+
region: string | null;
|
|
58
|
+
/**
|
|
59
|
+
* Call report identifier captured from the REGED message. Used by the
|
|
60
|
+
* underlying SDK to post call quality reports; exposed here so integrators
|
|
61
|
+
* can correlate client-side logs with server-side reports.
|
|
62
|
+
*/
|
|
63
|
+
callReportId: string | null;
|
|
44
64
|
constructor(params: TelnyxAIAgentConstructorParams);
|
|
45
65
|
/**
|
|
46
66
|
* Connects to the Telnyx WebRTC service and establishes a session with the AI agent.
|
package/dist/index.js
CHANGED
|
@@ -3535,6 +3535,26 @@ class Gt extends vt {
|
|
|
3535
3535
|
* Audio is negotiated as recvonly so agent speech can still be received.
|
|
3536
3536
|
*/
|
|
3537
3537
|
chatMode;
|
|
3538
|
+
/**
|
|
3539
|
+
* Datacenter identifier captured from the REGED message (e.g. `"ams3-prod"`).
|
|
3540
|
+
* Populated right before `agent.connected` is emitted. `null` until the
|
|
3541
|
+
* session registers, and always `null` on SDK versions that pre-date
|
|
3542
|
+
* team-telnyx/webrtc#583.
|
|
3543
|
+
*/
|
|
3544
|
+
dc = null;
|
|
3545
|
+
/**
|
|
3546
|
+
* Region identifier captured from the REGED message (e.g. `"eu-west"`).
|
|
3547
|
+
* Populated right before `agent.connected` is emitted. `null` until the
|
|
3548
|
+
* session registers, and always `null` on SDK versions that pre-date
|
|
3549
|
+
* team-telnyx/webrtc#583.
|
|
3550
|
+
*/
|
|
3551
|
+
region = null;
|
|
3552
|
+
/**
|
|
3553
|
+
* Call report identifier captured from the REGED message. Used by the
|
|
3554
|
+
* underlying SDK to post call quality reports; exposed here so integrators
|
|
3555
|
+
* can correlate client-side logs with server-side reports.
|
|
3556
|
+
*/
|
|
3557
|
+
callReportId = null;
|
|
3538
3558
|
constructor(e) {
|
|
3539
3559
|
super(), this.agentId = e.agentId, this.versionId = e.versionId || "main", this.conversationId = e.conversationId, this.debug = e.debug || !1, this.chatMode = e.chatMode || !1, this.activeCall = null, J.setLevel(this.debug ? "debug" : "info");
|
|
3540
3560
|
const t = {
|
|
@@ -3568,7 +3588,7 @@ class Gt extends vt {
|
|
|
3568
3588
|
* Emits an 'agent.disconnected' event before completing cleanup.
|
|
3569
3589
|
*/
|
|
3570
3590
|
async disconnect() {
|
|
3571
|
-
this.audioStreamMonitor.destroy(), this.telnyxRTC.disconnect(), this.telnyxRTC.off(x.Ready, this.onClientReady), this.telnyxRTC.off(x.Error, this.onClientOrSocketError), this.telnyxRTC.off(x.SocketError, this.onClientOrSocketError), this.telnyxRTC.off(x.Notification, this.onNotification), this.emit("agent.disconnected"), this.transcription.removeAllListeners(), Ge.removeAllListeners(), this.removeAllListeners();
|
|
3591
|
+
this.audioStreamMonitor.destroy(), this.telnyxRTC.disconnect(), this.telnyxRTC.off(x.Ready, this.onClientReady), this.telnyxRTC.off(x.Error, this.onClientOrSocketError), this.telnyxRTC.off(x.SocketError, this.onClientOrSocketError), this.telnyxRTC.off(x.Notification, this.onNotification), this.dc = null, this.region = null, this.callReportId = null, this.emit("agent.disconnected"), this.transcription.removeAllListeners(), Ge.removeAllListeners(), this.removeAllListeners();
|
|
3572
3592
|
}
|
|
3573
3593
|
/**
|
|
3574
3594
|
* Sends a text message to the AI agent during an active conversation.
|
|
@@ -3671,7 +3691,14 @@ class Gt extends vt {
|
|
|
3671
3691
|
this.audioStreamMonitor.setRemoteStream(e);
|
|
3672
3692
|
}
|
|
3673
3693
|
onClientReady = () => {
|
|
3674
|
-
this.
|
|
3694
|
+
const e = this.telnyxRTC;
|
|
3695
|
+
this.dc = e.dc ?? null, this.region = e.region ?? null, this.callReportId = e.callReportId ?? null;
|
|
3696
|
+
const t = {
|
|
3697
|
+
dc: this.dc,
|
|
3698
|
+
region: this.region,
|
|
3699
|
+
callReportId: this.callReportId
|
|
3700
|
+
};
|
|
3701
|
+
this.emit("agent.connected", t);
|
|
3675
3702
|
};
|
|
3676
3703
|
onClientOrSocketError = (e) => {
|
|
3677
3704
|
this.emit("agent.error", e);
|
package/dist/types.d.ts
CHANGED
|
@@ -20,8 +20,30 @@ export type AgentStateData = {
|
|
|
20
20
|
/** UTC timestamp (ISO 8601) when user stopped speaking and thinking state began. Only present when state is "thinking". */
|
|
21
21
|
thinkingStartedAt?: string;
|
|
22
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* Connection metadata captured from the REGED message sent by the Telnyx
|
|
25
|
+
* voice-sdk-proxy when the WebRTC session is established.
|
|
26
|
+
*
|
|
27
|
+
* - `dc`: datacenter identifier that handled the connection
|
|
28
|
+
* (e.g. `"ams3-prod"`, `"cn1-prod"`).
|
|
29
|
+
* - `region`: logical region the datacenter belongs to
|
|
30
|
+
* (e.g. `"eu-west"`, `"us-central"`).
|
|
31
|
+
* - `callReportId`: identifier used by the SDK to post periodic call
|
|
32
|
+
* quality reports to voice-sdk-proxy. Useful for correlating client
|
|
33
|
+
* sessions with server-side reports when debugging.
|
|
34
|
+
*
|
|
35
|
+
* All fields are nullable because the underlying SDK only populates them
|
|
36
|
+
* when the proxy advertises the corresponding values in the REGED message.
|
|
37
|
+
* `dc` and `region` require `@telnyx/webrtc` >= the version that ships
|
|
38
|
+
* team-telnyx/webrtc#583; on older versions they will always be `null`.
|
|
39
|
+
*/
|
|
40
|
+
export type AgentConnectionInfo = {
|
|
41
|
+
dc: string | null;
|
|
42
|
+
region: string | null;
|
|
43
|
+
callReportId: string | null;
|
|
44
|
+
};
|
|
23
45
|
export type AIAgentEvents = {
|
|
24
|
-
"agent.connected": () => void;
|
|
46
|
+
"agent.connected": (info: AgentConnectionInfo) => void;
|
|
25
47
|
"agent.disconnected": () => void;
|
|
26
48
|
"agent.error": (error: Error) => void;
|
|
27
49
|
"transcript.item": (item: TranscriptItem) => void;
|