@telnyx/ai-agent-lib 0.3.1-beta.0 → 0.3.1-beta.1

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 CHANGED
@@ -12,6 +12,14 @@ export type TelnyxAIAgentConstructorParams = {
12
12
  * Voice Activity Detection options for controlling speech detection and latency measurement.
13
13
  */
14
14
  vad?: VADOptions;
15
+ /**
16
+ * When true, the client connects in receive-only mode (no microphone).
17
+ * The WebRTC peer will negotiate audio as `recvonly` so the agent's audio
18
+ * is still received, but no local microphone permission is requested.
19
+ * Useful for chat-only / text-only experiences where you interact with
20
+ * the AI agent via `sendConversationMessage()`.
21
+ */
22
+ chatMode?: boolean;
15
23
  };
16
24
  export declare class TelnyxAIAgent extends EventEmitter<AIAgentEvents> {
17
25
  private telnyxRTC;
@@ -22,6 +30,11 @@ export declare class TelnyxAIAgent extends EventEmitter<AIAgentEvents> {
22
30
  debug: boolean;
23
31
  private audioStreamMonitor;
24
32
  activeCall: Call | null;
33
+ /**
34
+ * When true, the client operates in chat-only mode (no microphone).
35
+ * Audio is negotiated as recvonly so agent speech can still be received.
36
+ */
37
+ chatMode: boolean;
25
38
  constructor(params: TelnyxAIAgentConstructorParams);
26
39
  /**
27
40
  * Connects to the Telnyx WebRTC service and establishes a session with the AI agent.
package/dist/index.js CHANGED
@@ -489,7 +489,7 @@ class ln extends Q {
489
489
  super(), this.method = $.Ping, this.buildRequest({ method: this.method, voice_sdk_id: e, params: {} });
490
490
  }
491
491
  }
492
- var dn = "2.25.24-beta.1", gt = dn;
492
+ var dn = "2.25.24", gt = dn;
493
493
  class Zn extends Q {
494
494
  constructor(e, t, i, s, o = {}, r) {
495
495
  super(), this.method = "login";
@@ -560,8 +560,8 @@ class ri extends Q {
560
560
  class ai extends Q {
561
561
  constructor(e) {
562
562
  super(), this.method = "anonymous_login";
563
- const { target_type: t, target_id: i, target_version_id: s, target_params: o, userVariables: r, sessionId: l, reconnection: c } = e, u = { target_type: t, target_id: i, userVariables: r, reconnection: c, "User-Agent": { sdkVersion: gt, data: navigator.userAgent } };
564
- l && (u.sessid = l), s && (u.target_version_id = s), o && (u.target_params = o), this.buildRequest({ method: this.method, params: u });
563
+ const { target_type: t, target_id: i, target_version_id: s, userVariables: o, sessionId: r, reconnection: l } = e, c = { target_type: t, target_id: i, userVariables: o, reconnection: l, "User-Agent": { sdkVersion: gt, data: navigator.userAgent } };
564
+ r && (c.sessid = r), s && (c.target_version_id = s), this.buildRequest({ method: this.method, params: c });
565
565
  }
566
566
  }
567
567
  class ci {
@@ -631,7 +631,7 @@ class ci {
631
631
  _login({ type: e, onSuccess: t, onError: i }) {
632
632
  return O(this, void 0, void 0, (function* () {
633
633
  let s;
634
- s = e === "login" ? new Zn(this.options.login, this.options.password || this.options.passwd, this.options.login_token, this.sessionid, this.options.userVariables, !!he()) : new ai({ 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: !!he() });
634
+ s = e === "login" ? new Zn(this.options.login, this.options.password || this.options.passwd, this.options.login_token, this.sessionid, this.options.userVariables, !!he()) : new ai({ 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, sessionId: this.sessionid, userVariables: this.options.userVariables, reconnection: !!he() });
635
635
  const o = yield this.execute(s).catch(((r) => {
636
636
  this._handleLoginError(r), i && i(r);
637
637
  }));
@@ -3520,8 +3520,13 @@ class Vt extends vt {
3520
3520
  debug;
3521
3521
  audioStreamMonitor;
3522
3522
  activeCall;
3523
+ /**
3524
+ * When true, the client operates in chat-only mode (no microphone).
3525
+ * Audio is negotiated as recvonly so agent speech can still be received.
3526
+ */
3527
+ chatMode;
3523
3528
  constructor(e) {
3524
- super(), this.agentId = e.agentId, this.versionId = e.versionId || "main", this.conversationId = e.conversationId, this.debug = e.debug || !1, this.activeCall = null, J.setLevel(this.debug ? "debug" : "info");
3529
+ 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");
3525
3530
  const t = {
3526
3531
  target_id: e.agentId,
3527
3532
  target_type: "ai_assistant",
@@ -3629,7 +3634,8 @@ class Vt extends vt {
3629
3634
  const c = this.telnyxRTC.newCall({
3630
3635
  destinationNumber: "xxx",
3631
3636
  ...r,
3632
- audio: o ?? !0,
3637
+ audio: this.chatMode ? !1 : o ?? !0,
3638
+ ...this.chatMode ? { receiveOnlyAudio: !0 } : {},
3633
3639
  preferred_codecs: [i],
3634
3640
  customHeaders: l.length > 0 ? l : void 0
3635
3641
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@telnyx/ai-agent-lib",
3
3
  "private": false,
4
- "version": "0.3.1-beta.0",
4
+ "version": "0.3.1-beta.1",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -30,7 +30,7 @@
30
30
  "react-dom": "^19.1.0"
31
31
  },
32
32
  "dependencies": {
33
- "@telnyx/webrtc": "2.25.24-beta.1",
33
+ "@telnyx/webrtc": "^2.25.24",
34
34
  "eventemitter3": "^5.0.1",
35
35
  "jotai": "^2.12.5",
36
36
  "loglevel": "^1.9.2"
@@ -63,4 +63,4 @@
63
63
  ]
64
64
  },
65
65
  "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
66
- }
66
+ }