@telnyx/ai-agent-lib 0.2.2 → 0.2.4

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.
@@ -2,4 +2,4 @@ import type { PropsWithChildren } from "react";
2
2
  import type { TelnyxAIAgentConstructorParams } from "../client";
3
3
  import { TelnyxAIAgent } from "../client";
4
4
  export declare const ClientContext: import("react").Context<TelnyxAIAgent | null>;
5
- export declare const TelnyxAIAgentProvider: ({ children, agentId, environment, versionId, debug, }: PropsWithChildren & TelnyxAIAgentConstructorParams) => import("react/jsx-runtime").JSX.Element;
5
+ export declare const TelnyxAIAgentProvider: ({ children, agentId, environment, versionId, debug, vad, }: PropsWithChildren & TelnyxAIAgentConstructorParams) => import("react/jsx-runtime").JSX.Element;
package/dist/types.d.ts CHANGED
@@ -13,8 +13,10 @@ export type TranscriptItem = {
13
13
  };
14
14
  export type AgentStateData = {
15
15
  state: AgentState;
16
- /** Round-trip latency in milliseconds from when user stopped speaking until agent response began. Only present when state is "speaking". */
17
- latencyMs?: number;
16
+ /** Latency in milliseconds from when user stopped speaking until agent response began. Only present when state is "speaking". */
17
+ userPerceivedLatencyMs?: number;
18
+ /** Latency in milliseconds for the initial agent greeting (first speech). Only present on first "speaking" state. */
19
+ greetingLatencyMs?: number;
18
20
  /** UTC timestamp (ISO 8601) when user stopped speaking and thinking state began. Only present when state is "thinking". */
19
21
  thinkingStartedAt?: string;
20
22
  };
@@ -30,5 +32,36 @@ export type AIAgentEvents = {
30
32
  export type AgentState = "speaking" | "listening" | "thinking";
31
33
  export type TranscriptEvents = Pick<AIAgentEvents, "transcript.item">;
32
34
  export type AgentStateEvents = Pick<AIAgentEvents, "conversation.agent.state">;
35
+ /**
36
+ * Configuration options for Voice Activity Detection (VAD).
37
+ * These thresholds control how the library detects user speech and measures latency.
38
+ */
39
+ export type VADOptions = {
40
+ /**
41
+ * Volume threshold (0-255) for detecting speech.
42
+ * Audio levels above this value are considered speech.
43
+ * @default 10
44
+ */
45
+ volumeThreshold?: number;
46
+ /**
47
+ * Duration of silence (ms) before triggering "thinking" state.
48
+ * Lower values = faster response but may cut off natural pauses.
49
+ * Higher values = more tolerant of pauses but slower state transitions.
50
+ * @default 1000
51
+ */
52
+ silenceDurationMs?: number;
53
+ /**
54
+ * Minimum speech duration (ms) to count as real user speech.
55
+ * Filters out brief noise spikes. Short words like "yes"/"no" are ~150ms.
56
+ * @default 100
57
+ */
58
+ minSpeechDurationMs?: number;
59
+ /**
60
+ * Maximum latency (ms) to report. Values above this are considered
61
+ * stale (likely from old noise) and won't be reported.
62
+ * @default undefined (no limit)
63
+ */
64
+ maxLatencyMs?: number;
65
+ };
33
66
  export type { INotification, Call, ICallOptions };
34
67
  export { SwEvent };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@telnyx/ai-agent-lib",
3
3
  "private": false,
4
- "version": "0.2.2",
4
+ "version": "0.2.4",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -21,7 +21,7 @@
21
21
  "react-dom": "^19.1.0"
22
22
  },
23
23
  "dependencies": {
24
- "@telnyx/webrtc": "^2.25.12",
24
+ "@telnyx/webrtc": "^2.25.14",
25
25
  "eventemitter3": "^5.0.1",
26
26
  "jotai": "^2.12.5",
27
27
  "loglevel": "^1.9.2"