@absolutejs/voice 0.0.22-beta.506 → 0.0.22-beta.508

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.
@@ -0,0 +1,16 @@
1
+ import { type CreateLiveAgentConsoleOptions, type LiveAgentConsole, type LiveAgentConsoleState } from "../client/liveAgentConsole";
2
+ export type VoiceLiveAgentConsoleServiceOptions = CreateLiveAgentConsoleOptions & {
3
+ takeoverButtonLabel?: string;
4
+ title?: string;
5
+ };
6
+ export declare class VoiceLiveAgentConsoleService {
7
+ build(options: VoiceLiveAgentConsoleServiceOptions): {
8
+ releaseTakeover: () => void;
9
+ setCaller: (caller: Parameters<LiveAgentConsole["setCaller"]>[0]) => void;
10
+ state: import("@angular/core").Signal<LiveAgentConsoleState>;
11
+ stop: () => void;
12
+ takeover: (reason?: string) => void;
13
+ takeoverButtonLabel: string;
14
+ title: string;
15
+ };
16
+ }
@@ -0,0 +1,22 @@
1
+ export type BrowserVoiceSupportProbe = {
2
+ hasAudioContext: boolean;
3
+ hasAudioWorklet: boolean;
4
+ hasGetUserMedia: boolean;
5
+ hasMediaRecorder: boolean;
6
+ hasOpusEncoding: boolean;
7
+ hasRTCPeerConnection: boolean;
8
+ hasWebSocket: boolean;
9
+ isInsecureContext: boolean;
10
+ isIos: boolean;
11
+ isSafari: boolean;
12
+ requiresUserGestureToResumeAudio: boolean;
13
+ userAgent: string;
14
+ };
15
+ export type BrowserVoiceSupportReport = {
16
+ blockers: string[];
17
+ capabilities: BrowserVoiceSupportProbe;
18
+ ok: boolean;
19
+ warnings: string[];
20
+ };
21
+ export declare const probeBrowserVoiceSupport: (globalScope?: typeof globalThis) => BrowserVoiceSupportProbe;
22
+ export declare const checkBrowserVoiceSupport: (globalScope?: typeof globalThis) => BrowserVoiceSupportReport;
@@ -0,0 +1,29 @@
1
+ import type { StoredVoiceTraceEvent } from "../trace";
2
+ export type VoiceTrafficBucket = {
3
+ bucketKey: string;
4
+ callsCompleted: number;
5
+ callsFailed: number;
6
+ callsTransferred: number;
7
+ callsVoicemail: number;
8
+ callsTotal: number;
9
+ totalDurationMs: number;
10
+ };
11
+ export type VoiceTrafficSummary = {
12
+ buckets: VoiceTrafficBucket[];
13
+ callsByDisposition: Record<string, number>;
14
+ transferReasons: Record<string, number>;
15
+ topTransferTargets: Array<{
16
+ count: number;
17
+ target: string;
18
+ }>;
19
+ totals: VoiceTrafficBucket;
20
+ windowEndMs: number;
21
+ windowStartMs: number;
22
+ };
23
+ export type SummarizeVoiceCallTrafficOptions = {
24
+ bucketBy?: "day" | "hour" | "month";
25
+ events: ReadonlyArray<StoredVoiceTraceEvent>;
26
+ fromMs?: number;
27
+ toMs?: number;
28
+ };
29
+ export declare const summarizeVoiceCallTraffic: (options: SummarizeVoiceCallTrafficOptions) => VoiceTrafficSummary;
@@ -0,0 +1,28 @@
1
+ import { type CreateLiveCallViewerOptions, type LiveCallTimelineEvent, type LiveCallViewState, type LiveCallViewer } from "./liveCallViewer";
2
+ import type { VoiceCallerMemorySnapshot } from "../callerMemory";
3
+ export type LiveAgentConsoleState = {
4
+ caller?: VoiceCallerMemorySnapshot;
5
+ hasTakeover: boolean;
6
+ recentTimeline: LiveCallTimelineEvent[];
7
+ takeoverAt?: number;
8
+ takeoverReason?: string;
9
+ view: LiveCallViewState;
10
+ };
11
+ export type CreateLiveAgentConsoleOptions = CreateLiveCallViewerOptions & {
12
+ /** Recent timeline window length. Default 12. */
13
+ recentLimit?: number;
14
+ /** Resolves the caller memory snapshot for this session (fetched once on attach). */
15
+ resolveCaller?: () => Promise<VoiceCallerMemorySnapshot | undefined> | VoiceCallerMemorySnapshot | undefined;
16
+ };
17
+ export type LiveAgentConsole = {
18
+ getState: () => LiveAgentConsoleState;
19
+ noteAgentAudio: (at?: number) => void;
20
+ notePartial: (text: string, at?: number) => void;
21
+ noteTranscript: (text: string, at?: number) => void;
22
+ releaseTakeover: () => void;
23
+ setCaller: (caller: VoiceCallerMemorySnapshot | undefined) => void;
24
+ subscribe: (listener: () => void) => () => void;
25
+ takeover: (reason?: string) => void;
26
+ viewer: LiveCallViewer;
27
+ };
28
+ export declare const createLiveAgentConsole: (options: CreateLiveAgentConsoleOptions) => LiveAgentConsole;
@@ -0,0 +1,74 @@
1
+ import { type VoicePriceBook } from "./costAccounting";
2
+ export type VoiceCostProfile = {
3
+ /** Stored callers? Set to true to include caller-memory storage costs (per snapshot, monthly). Default false (we don't model storage here). */
4
+ includeCallerMemory?: boolean;
5
+ /** Inbound calls per day. */
6
+ inboundPerDay?: number;
7
+ /** Average input tokens per agent turn. */
8
+ inputTokensPerTurn: number;
9
+ /** LLM model id used for provider:model price lookup. */
10
+ llmModel: string;
11
+ /** LLM provider — must match price book namespace. */
12
+ llmProvider: string;
13
+ /** Average minutes per call. */
14
+ minutesPerCall: number;
15
+ /** Outbound calls per day. */
16
+ outboundPerDay?: number;
17
+ /** Average output tokens per agent turn. */
18
+ outputTokensPerTurn: number;
19
+ /** STT model. */
20
+ sttModel?: string;
21
+ /** STT provider. */
22
+ sttProvider?: string;
23
+ /** Telephony provider key in the price book (e.g. 'twilio', 'telnyx'). */
24
+ telephonyProvider?: string;
25
+ /** Total turns per call. */
26
+ turnsPerCall: number;
27
+ /** Average TTS characters spoken per agent turn. */
28
+ ttsCharsPerTurn: number;
29
+ /** TTS model / voice id. */
30
+ ttsModel?: string;
31
+ /** TTS provider. */
32
+ ttsProvider?: string;
33
+ };
34
+ export type VoiceCostPrediction = {
35
+ callsPerDay: number;
36
+ monthly: {
37
+ llmUsd: number;
38
+ sttUsd: number;
39
+ telephonyUsd: number;
40
+ totalUsd: number;
41
+ ttsUsd: number;
42
+ };
43
+ perCall: {
44
+ llmUsd: number;
45
+ sttUsd: number;
46
+ telephonyUsd: number;
47
+ totalUsd: number;
48
+ ttsUsd: number;
49
+ };
50
+ };
51
+ export type PredictVoiceCallCostInput = {
52
+ priceBook?: VoicePriceBook;
53
+ profile: VoiceCostProfile;
54
+ };
55
+ export declare const predictVoiceCallCost: (input: PredictVoiceCallCostInput) => VoiceCostPrediction;
56
+ export type VoiceCostScenarioComparison = {
57
+ delta: {
58
+ monthlyUsd: number;
59
+ perCallUsd: number;
60
+ };
61
+ prediction: VoiceCostPrediction;
62
+ scenarioId: string;
63
+ };
64
+ export declare const compareVoiceCostScenarios: (input: {
65
+ baselineId: string;
66
+ priceBook?: VoicePriceBook;
67
+ scenarios: ReadonlyArray<{
68
+ id: string;
69
+ profile: VoiceCostProfile;
70
+ }>;
71
+ }) => {
72
+ baseline: VoiceCostPrediction;
73
+ scenarios: VoiceCostScenarioComparison[];
74
+ };
@@ -0,0 +1,37 @@
1
+ export type VoiceDTMFDigit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "*" | "#";
2
+ export declare const VOICE_DTMF_DIGITS: readonly VoiceDTMFDigit[];
3
+ export type VoiceDTMFCollectorState = {
4
+ status: "collecting";
5
+ digits: string;
6
+ } | {
7
+ status: "completed";
8
+ digits: string;
9
+ reason: "length" | "terminator";
10
+ } | {
11
+ status: "cancelled";
12
+ digits: string;
13
+ } | {
14
+ status: "rejected";
15
+ digits: string;
16
+ reason: "invalid" | "timeout" | "too-short";
17
+ };
18
+ export type CreateVoiceDTMFCollectorOptions = {
19
+ prompt: string;
20
+ minLength?: number;
21
+ maxLength?: number;
22
+ terminator?: VoiceDTMFDigit | null;
23
+ timeoutMs?: number;
24
+ interDigitTimeoutMs?: number;
25
+ validator?: (digits: string) => boolean | string;
26
+ now?: () => number;
27
+ };
28
+ export declare const collectVoiceDTMFInput: (options: CreateVoiceDTMFCollectorOptions) => {
29
+ cancel(): VoiceDTMFCollectorState;
30
+ feed(digit: string, at?: number): VoiceDTMFCollectorState;
31
+ getState: () => VoiceDTMFCollectorState;
32
+ prompt: string;
33
+ subscribe(listener: (state: VoiceDTMFCollectorState) => void): () => void;
34
+ tick(at?: number): VoiceDTMFCollectorState;
35
+ };
36
+ export type VoiceDTMFCollector = ReturnType<typeof collectVoiceDTMFInput>;
37
+ export declare const validateVoiceDTMFLuhn: (digits: string) => boolean;
@@ -0,0 +1,23 @@
1
+ export type VoiceHoldAudioCue = {
2
+ audioUrl?: string;
3
+ metadata?: Record<string, unknown>;
4
+ text?: string;
5
+ };
6
+ export type VoiceHoldAudioDriverOptions = {
7
+ /** Cooldown between hold cues so we don't spam the caller. Default 4_000ms. */
8
+ cooldownMs?: number;
9
+ /** Cues to play. Picked in order; cycles back to start. */
10
+ cues?: ReadonlyArray<VoiceHoldAudioCue>;
11
+ /** Operator callback invoked when a cue is selected. Wire to TTS or a pre-rendered clip. */
12
+ onCue: (cue: VoiceHoldAudioCue) => Promise<void> | void;
13
+ /** Minimum agent-thinking duration before the first cue fires. Default 1_500ms. */
14
+ thinkingThresholdMs?: number;
15
+ };
16
+ export type VoiceHoldAudioDriver = {
17
+ /** Note that the agent has started thinking (e.g. tool call dispatched). */
18
+ noteThinking: (timestampMs?: number) => void;
19
+ /** Note that the agent has produced output (e.g. assistant text / audio). */
20
+ noteResponse: (timestampMs?: number) => void;
21
+ reset: () => void;
22
+ };
23
+ export declare const createVoiceHoldAudioDriver: (options: VoiceHoldAudioDriverOptions) => VoiceHoldAudioDriver;
@@ -0,0 +1,34 @@
1
+ export type VoiceIceServer = {
2
+ credential?: string;
3
+ urls: string | string[];
4
+ username?: string;
5
+ };
6
+ export type CreateCoturnIceServersInput = {
7
+ /** TURN realm. */
8
+ realm: string;
9
+ /** Credential TTL in seconds. Default 3600. */
10
+ ttlSec?: number;
11
+ /** Coturn shared secret (use_auth_secret). */
12
+ sharedSecret: string;
13
+ /** TURN endpoint host:port (e.g. 'turn.example.com:3478'). */
14
+ turnHost: string;
15
+ /** Username to derive ephemeral credential for. */
16
+ username: string;
17
+ /** Optional STUN endpoints to prepend. Default ['stun:stun.l.google.com:19302']. */
18
+ stunUrls?: string[];
19
+ /** UTC unix-seconds NOW override for testing. */
20
+ now?: number;
21
+ /** SHA-1 HMAC implementation for testing. Defaults to crypto.subtle. */
22
+ hmacSha1Base64?: (key: string, message: string) => Promise<string>;
23
+ };
24
+ /**
25
+ * Builds an iceServers array using the coturn `use-auth-secret` REST API
26
+ * pattern: username = `${expires}:${callerId}`, credential = HMAC-SHA1(secret, username) base64-encoded.
27
+ */
28
+ export declare const createCoturnIceServers: (input: CreateCoturnIceServersInput) => Promise<VoiceIceServer[]>;
29
+ export type CreateTwilioNTSIceServersInput = {
30
+ accountSid: string;
31
+ authToken: string;
32
+ fetch?: typeof fetch;
33
+ };
34
+ export declare const createTwilioNTSIceServers: (input: CreateTwilioNTSIceServersInput) => Promise<VoiceIceServer[]>;
package/dist/index.d.ts CHANGED
@@ -289,4 +289,16 @@ export { buildVoiceMultilingualProofReadinessCheck, renderVoiceMultilingualProof
289
289
  export type { VoiceMultilingualLanguageCode, VoiceMultilingualProofAdapterEntry, VoiceMultilingualProofAdapterReport, VoiceMultilingualProofDefaultThresholds, VoiceMultilingualProofLanguageMetrics, VoiceMultilingualProofLanguageReport, VoiceMultilingualProofLanguageThresholds, VoiceMultilingualProofOptions, VoiceMultilingualProofReadinessCheck, VoiceMultilingualProofReadinessOptions, VoiceMultilingualProofReport, } from "./multilingualProof";
290
290
  export { buildVoiceMonitorPlan, createVoiceInMemoryMonitorRegistry, createVoiceLiveMonitorRoutes, createVoiceMonitorRuntimeBinding, createVoiceMonitorSession, } from "./monitor";
291
291
  export type { VoiceMonitorAudioEvent, VoiceMonitorAudioSource, VoiceMonitorAuthenticate, VoiceMonitorAuthenticateInput, VoiceMonitorControlAck, VoiceMonitorControlHandler, VoiceMonitorControlHandlerInput, VoiceMonitorControlMessage, VoiceMonitorMutableRegistry, VoiceMonitorPlan, VoiceMonitorPlanInput, VoiceMonitorRegistry, VoiceMonitorRegistryRegisterInput, VoiceLiveMonitorRoutesOptions, VoiceMonitorRuntimeBindingOptions, VoiceMonitorSessionRecord, } from "./monitor";
292
+ export { compareVoiceCostScenarios, predictVoiceCallCost, } from "./costPredictor";
293
+ export type { PredictVoiceCallCostInput, VoiceCostPrediction, VoiceCostProfile, VoiceCostScenarioComparison, } from "./costPredictor";
294
+ export { createCoturnIceServers, createTwilioNTSIceServers, } from "./iceServers";
295
+ export type { CreateCoturnIceServersInput, CreateTwilioNTSIceServersInput, VoiceIceServer, } from "./iceServers";
296
+ export { createVoiceHoldAudioDriver } from "./holdAudio";
297
+ export type { VoiceHoldAudioCue, VoiceHoldAudioDriver, VoiceHoldAudioDriverOptions, } from "./holdAudio";
298
+ export { createVoicePromptInjectionGuard, DEFAULT_VOICE_PROMPT_INJECTION_RULES, } from "./promptInjectionGuard";
299
+ export type { VoicePromptInjectionRule, VoicePromptInjectionVerdict, VoicePromptInjectionGuard, CreateVoicePromptInjectionGuardOptions, } from "./promptInjectionGuard";
300
+ export { createVoicePostCallSurvey, DEFAULT_VOICE_POST_CALL_SURVEY_QUESTIONS, summarizeVoicePostCallSurveys, } from "./postCallSurvey";
301
+ export type { VoicePostCallSurvey, VoicePostCallSurveyAnswer, VoicePostCallSurveyQuestion, VoicePostCallSurveyResponse, CreateVoicePostCallSurveyOptions, } from "./postCallSurvey";
302
+ export { collectVoiceDTMFInput, validateVoiceDTMFLuhn, VOICE_DTMF_DIGITS, } from "./dtmfCollector";
303
+ export type { VoiceDTMFCollector, VoiceDTMFCollectorState, VoiceDTMFDigit, CreateVoiceDTMFCollectorOptions, } from "./dtmfCollector";
292
304
  export * from "./types";