getpatter 0.4.4 → 0.5.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.d.mts CHANGED
@@ -1,6 +1,245 @@
1
1
  import { EventEmitter } from 'events';
2
2
  import { Request, Response, NextFunction, Express } from 'express';
3
3
 
4
+ /** Twilio carrier credentials holder for Patter. */
5
+ interface TwilioCarrierOptions {
6
+ /** Twilio Account SID. Falls back to TWILIO_ACCOUNT_SID env var. */
7
+ accountSid?: string;
8
+ /** Twilio Auth Token. Falls back to TWILIO_AUTH_TOKEN env var. */
9
+ authToken?: string;
10
+ }
11
+ /**
12
+ * Twilio telephony carrier — holds Account SID + Auth Token.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import * as twilio from "getpatter/carriers/twilio";
17
+ * const carrier = new twilio.Carrier(); // reads env
18
+ * const carrier = new twilio.Carrier({ accountSid: "AC...", authToken: "..." });
19
+ * ```
20
+ */
21
+ declare class Carrier$1 {
22
+ readonly kind: "twilio";
23
+ readonly accountSid: string;
24
+ readonly authToken: string;
25
+ constructor(opts?: TwilioCarrierOptions);
26
+ }
27
+
28
+ /** Telnyx carrier credentials holder for Patter. */
29
+ interface TelnyxCarrierOptions {
30
+ /** Telnyx API key. Falls back to TELNYX_API_KEY env var. */
31
+ apiKey?: string;
32
+ /** Telnyx connection ID. Falls back to TELNYX_CONNECTION_ID env var. */
33
+ connectionId?: string;
34
+ /** Optional Ed25519 public key for webhook signature verification. Falls back to TELNYX_PUBLIC_KEY env var. */
35
+ publicKey?: string;
36
+ }
37
+ /**
38
+ * Telnyx telephony carrier — holds API key, connection ID, and optional webhook public key.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * import * as telnyx from "getpatter/carriers/telnyx";
43
+ * const carrier = new telnyx.Carrier(); // reads env
44
+ * const carrier = new telnyx.Carrier({ apiKey: "KEY...", connectionId: "123" });
45
+ * ```
46
+ */
47
+ declare class Carrier {
48
+ readonly kind: "telnyx";
49
+ readonly apiKey: string;
50
+ readonly connectionId: string;
51
+ readonly publicKey: string | undefined;
52
+ constructor(opts?: TelnyxCarrierOptions);
53
+ }
54
+
55
+ /** OpenAI Realtime engine — marker class for Patter client dispatch. */
56
+ interface RealtimeOptions {
57
+ /** API key. Falls back to OPENAI_API_KEY env var when omitted. */
58
+ apiKey?: string;
59
+ /** Realtime model. Defaults to gpt-4o-mini-realtime-preview. */
60
+ model?: string;
61
+ /** Voice preset. Defaults to alloy. */
62
+ voice?: string;
63
+ }
64
+ /**
65
+ * OpenAI Realtime engine marker.
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * import * as openai from "getpatter/engines/openai";
70
+ * const engine = new openai.Realtime(); // reads OPENAI_API_KEY
71
+ * const engine = new openai.Realtime({ voice: "alloy" });
72
+ * ```
73
+ */
74
+ declare class Realtime {
75
+ readonly kind: "openai_realtime";
76
+ readonly apiKey: string;
77
+ readonly model: string;
78
+ readonly voice: string;
79
+ constructor(opts?: RealtimeOptions);
80
+ }
81
+
82
+ /** ElevenLabs ConvAI engine — marker class for Patter client dispatch. */
83
+ interface ConvAIOptions {
84
+ /** API key. Falls back to ELEVENLABS_API_KEY env var when omitted. */
85
+ apiKey?: string;
86
+ /** ElevenLabs Agent ID. Falls back to ELEVENLABS_AGENT_ID env var when omitted. */
87
+ agentId?: string;
88
+ /** Voice ID to override the agent's default voice. */
89
+ voice?: string;
90
+ }
91
+ /**
92
+ * ElevenLabs ConvAI engine marker.
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * import * as elevenlabs from "getpatter/engines/elevenlabs";
97
+ * const engine = new elevenlabs.ConvAI(); // reads env vars
98
+ * const engine = new elevenlabs.ConvAI({ agentId: "agent_..." });
99
+ * ```
100
+ */
101
+ declare class ConvAI {
102
+ readonly kind: "elevenlabs_convai";
103
+ readonly apiKey: string;
104
+ readonly agentId: string;
105
+ readonly voice: string | undefined;
106
+ constructor(opts?: ConvAIOptions);
107
+ }
108
+
109
+ /** Tunnel marker classes for Patter. Dispatched by the client to decide how to expose local servers. */
110
+ /**
111
+ * Cloudflare Quick Tunnel marker — ask Patter to start a cloudflared tunnel.
112
+ *
113
+ * @example
114
+ * ```ts
115
+ * import { CloudflareTunnel } from "getpatter/tunnels";
116
+ * const tunnel = new CloudflareTunnel();
117
+ * ```
118
+ */
119
+ declare class CloudflareTunnel {
120
+ readonly kind: "cloudflare";
121
+ }
122
+ /**
123
+ * Static hostname marker — use a pre-existing public hostname (no tunnel).
124
+ *
125
+ * @example
126
+ * ```ts
127
+ * import { Static } from "getpatter/tunnels";
128
+ * const tunnel = new Static({ hostname: "agent.example.com" });
129
+ * ```
130
+ */
131
+ declare class Static {
132
+ readonly kind: "static";
133
+ readonly hostname: string;
134
+ constructor(opts: {
135
+ hostname: string;
136
+ });
137
+ }
138
+
139
+ /**
140
+ * Public API primitives — `Tool` and `Guardrail` classes, plus the
141
+ * `tool()` / `guardrail()` factory functions.
142
+ *
143
+ * These mirror the Python SDK's `patter.Tool` / `patter.Guardrail`. The
144
+ * classes are structurally compatible with the existing `Guardrail`
145
+ * interface and `ToolDefinition` shape used internally, so code that
146
+ * consumed either form keeps working.
147
+ */
148
+
149
+ interface GuardrailOptions {
150
+ /** Name for logging when triggered. */
151
+ name: string;
152
+ /** List of terms that trigger the guardrail (case-insensitive). */
153
+ blockedTerms?: string[];
154
+ /** Custom check function — return true to block the response. */
155
+ check?: (text: string) => boolean;
156
+ /** Replacement text spoken when guardrail triggers. */
157
+ replacement?: string;
158
+ }
159
+ /**
160
+ * Guardrail definition. Structurally matches the internal `Guardrail`
161
+ * interface so existing code consuming plain objects keeps working.
162
+ *
163
+ * @example
164
+ * ```ts
165
+ * import { Guardrail } from "getpatter";
166
+ * const rail = new Guardrail({ name: "profanity", blockedTerms: ["badword"] });
167
+ * ```
168
+ */
169
+ declare class Guardrail$1 {
170
+ readonly name: string;
171
+ readonly blockedTerms?: string[];
172
+ readonly check?: (text: string) => boolean;
173
+ readonly replacement: string;
174
+ constructor(opts: GuardrailOptions);
175
+ }
176
+ /** Factory helper mirroring Python's `guardrail(...)` function. */
177
+ declare function guardrail(opts: GuardrailOptions): Guardrail$1;
178
+ type ToolHandler = (args: Record<string, unknown>, context: Record<string, unknown>) => Promise<string>;
179
+ interface ToolOptions {
180
+ /** Tool name (visible to the LLM). */
181
+ name: string;
182
+ /** What the tool does (visible to the LLM). */
183
+ description?: string;
184
+ /** JSON Schema for tool arguments. */
185
+ parameters?: Record<string, unknown>;
186
+ /** Async function called in-process when the LLM invokes the tool. */
187
+ handler?: ToolHandler;
188
+ /** URL to POST to when the LLM invokes the tool. */
189
+ webhookUrl?: string;
190
+ }
191
+ /**
192
+ * Tool definition. Structurally matches `ToolDefinition` so it drops
193
+ * directly into `agent({ tools: [...] })`.
194
+ *
195
+ * Exactly one of `handler` or `webhookUrl` must be provided.
196
+ *
197
+ * @example
198
+ * ```ts
199
+ * import { Tool } from "getpatter";
200
+ * const t = new Tool({
201
+ * name: "check_menu",
202
+ * description: "Check available menu items",
203
+ * handler: async () => JSON.stringify({ items: ["margherita"] }),
204
+ * });
205
+ * ```
206
+ */
207
+ declare class Tool implements ToolDefinition {
208
+ readonly name: string;
209
+ readonly description: string;
210
+ readonly parameters: Record<string, unknown>;
211
+ readonly handler?: ToolHandler;
212
+ readonly webhookUrl?: string;
213
+ constructor(opts: ToolOptions);
214
+ }
215
+ /** Factory helper mirroring Python's `tool(...)` function. */
216
+ declare function tool(opts: ToolOptions): Tool;
217
+
218
+ /**
219
+ * Shared STT / TTS adapter dispatch.
220
+ *
221
+ * In v0.5.0+ callers always pass pre-instantiated adapters (``agent.stt`` /
222
+ * ``agent.tts`` are ``STTAdapter`` / ``TTSAdapter`` instances), so these
223
+ * helpers are thin pass-throughs that return the instance or null. Kept as
224
+ * functions so the Twilio/Telnyx bridges have a single dispatch point.
225
+ */
226
+
227
+ interface STTTranscript {
228
+ text: string;
229
+ isFinal?: boolean;
230
+ }
231
+ type STTTranscriptCallback = (t: STTTranscript) => Promise<void> | void;
232
+ /** Shape shared by every STT adapter in the SDK. */
233
+ interface STTAdapter {
234
+ connect(): Promise<void>;
235
+ sendAudio(pcm: Buffer): void | Promise<void>;
236
+ onTranscript(cb: STTTranscriptCallback): void;
237
+ close(): void | Promise<void>;
238
+ }
239
+ interface TTSAdapter {
240
+ synthesizeStream(text: string): AsyncIterable<Buffer>;
241
+ }
242
+
4
243
  interface IncomingMessage {
5
244
  readonly text: string;
6
245
  readonly callId: string;
@@ -108,32 +347,34 @@ interface Call {
108
347
  }
109
348
  interface LocalOptions {
110
349
  /**
111
- * Optional — when omitted, local mode is auto-detected from the presence of
112
- * ``twilioSid`` or ``telnyxKey`` (matches the Python SDK which treats
113
- * ``Patter(twilio_sid=...)`` as local mode by default).
350
+ * Local mode is auto-detected when a ``carrier`` is passed. Pass
351
+ * ``mode: 'local'`` to force local mode explicitly.
114
352
  */
115
353
  mode?: 'local';
116
- twilioSid?: string;
117
- twilioToken?: string;
118
- openaiKey?: string;
119
- phoneNumber: string;
120
- webhookUrl?: string;
121
- telephonyProvider?: 'twilio' | 'telnyx';
122
- telnyxKey?: string;
123
- telnyxConnectionId?: string;
124
354
  /**
125
- * Telnyx Ed25519 public key (base64-encoded, DER/SPKI format) for webhook
126
- * signature verification. When provided, unauthenticated requests are rejected.
355
+ * Telephony carrier instance. Required for local mode.
356
+ *
357
+ * @example
358
+ * ```ts
359
+ * import { Patter, Twilio } from "getpatter";
360
+ * const phone = new Patter({ carrier: new Twilio(), phoneNumber: "+1..." });
361
+ * ```
127
362
  */
128
- telnyxPublicKey?: string;
363
+ carrier: Carrier$1 | Carrier;
129
364
  /**
130
- * Provider-level Deepgram API key. When set, agents that don't override
131
- * ``agent.deepgramKey`` / ``agent.stt`` use this as the default STT key.
132
- * Mirrors Python's ``Patter(deepgram_key=...)``.
365
+ * Tunnel configuration. Accepts a tunnel instance, ``true`` (alias for
366
+ * ``new CloudflareTunnel()``), or ``false`` / omitted (no tunnel).
133
367
  */
134
- deepgramKey?: string;
135
- /** Provider-level ElevenLabs API key (same semantics as ``deepgramKey``). */
136
- elevenlabsKey?: string;
368
+ tunnel?: CloudflareTunnel | Static | boolean;
369
+ phoneNumber: string;
370
+ webhookUrl?: string;
371
+ /**
372
+ * @internal — allows ``StreamHandler`` to build the default OpenAI
373
+ * ``LLMLoop`` when no ``onMessage`` handler is supplied. The
374
+ * ``OpenAIRealtime`` engine instance carries its own key when one is
375
+ * used via ``phone.agent({ engine: new OpenAIRealtime({ apiKey }) })``.
376
+ */
377
+ openaiKey?: string;
137
378
  }
138
379
  interface Guardrail {
139
380
  /** Name for logging when triggered */
@@ -189,23 +430,40 @@ interface BackgroundAudioPlayer$1 {
189
430
  }
190
431
  interface AgentOptions {
191
432
  systemPrompt: string;
433
+ /**
434
+ * Voice preset. When ``engine`` is provided, its ``voice`` is used unless
435
+ * explicitly overridden here.
436
+ */
192
437
  voice?: string;
438
+ /**
439
+ * LLM / Realtime model. When ``engine`` is provided, its ``model`` is used
440
+ * unless explicitly overridden here.
441
+ */
193
442
  model?: string;
194
443
  language?: string;
195
444
  firstMessage?: string;
196
- tools?: ToolDefinition[];
445
+ /** Tool definitions — ``Tool`` class instances from ``getpatter``. */
446
+ tools?: Array<Tool>;
447
+ /**
448
+ * Realtime / ConvAI engine instance. When present, the agent runs in the
449
+ * matching mode (``openai_realtime`` or ``elevenlabs_convai``). When absent,
450
+ * pipeline mode is selected if ``stt`` and ``tts`` are provided.
451
+ */
452
+ engine?: Realtime | ConvAI;
453
+ /**
454
+ * Provider mode. Normally derived from ``engine`` / ``stt`` + ``tts``. Pass
455
+ * ``'pipeline'`` explicitly when building a pipeline-mode agent without
456
+ * an engine instance.
457
+ */
197
458
  provider?: 'openai_realtime' | 'elevenlabs_convai' | 'pipeline';
198
- elevenlabsKey?: string;
199
- elevenlabsAgentId?: string;
200
- deepgramKey?: string;
201
- /** STT provider config for pipeline mode. Use ``Patter.deepgram()`` or ``Patter.whisper()``. */
202
- stt?: STTConfig;
203
- /** TTS provider config for pipeline mode. Use ``Patter.elevenlabs()`` or ``Patter.openaiTts()``. */
204
- tts?: TTSConfig;
459
+ /** Pre-instantiated STT adapter (e.g. ``new DeepgramSTT({ apiKey })``). */
460
+ stt?: STTAdapter;
461
+ /** Pre-instantiated TTS adapter (e.g. ``new ElevenLabsTTS({ apiKey })``). */
462
+ tts?: TTSAdapter;
205
463
  /** Dynamic variables for ``{placeholder}`` substitution in systemPrompt at call time. */
206
464
  variables?: Record<string, string>;
207
- /** Output guardrails — filter AI responses before TTS */
208
- guardrails?: Guardrail[];
465
+ /** Output guardrails — ``Guardrail`` class instances from ``getpatter``. */
466
+ guardrails?: Array<Guardrail>;
209
467
  /** Pipeline hooks — intercept and transform data at each pipeline stage (pipeline mode only). */
210
468
  hooks?: PipelineHooks;
211
469
  /** Text transforms applied to LLM output before TTS (pipeline mode only).
@@ -272,52 +530,13 @@ interface LocalCallOptions {
272
530
  ringTimeout?: number;
273
531
  }
274
532
 
275
- /**
276
- * Deepgram STT config. Tune latency via ``endpointingMs`` / ``utteranceEndMs``
277
- * — mirrors Python's ``Patter.deepgram(endpointing_ms=..., utterance_end_ms=...)``.
278
- */
279
- declare function deepgram(opts: {
280
- apiKey: string;
281
- language?: string;
282
- model?: string;
283
- endpointingMs?: number;
284
- utteranceEndMs?: number | null;
285
- smartFormat?: boolean;
286
- interimResults?: boolean;
287
- vadEvents?: boolean;
288
- }): STTConfig;
289
- declare function whisper(opts: {
290
- apiKey: string;
291
- language?: string;
292
- }): STTConfig;
293
- declare function elevenlabs(opts: {
294
- apiKey: string;
295
- voice?: string;
296
- }): TTSConfig;
297
- declare function openaiTts(opts: {
298
- apiKey: string;
299
- voice?: string;
300
- }): TTSConfig;
301
- declare function cartesia(opts: {
302
- apiKey: string;
303
- voice?: string;
304
- }): TTSConfig;
305
- declare function rime(opts: {
306
- apiKey: string;
307
- voice?: string;
308
- }): TTSConfig;
309
- declare function lmnt(opts: {
310
- apiKey: string;
311
- voice?: string;
312
- }): TTSConfig;
313
-
314
533
  declare class Patter {
315
534
  readonly apiKey: string;
316
535
  private readonly backendUrl;
317
536
  private readonly restUrl;
318
537
  private readonly connection;
319
538
  private readonly mode;
320
- private readonly localConfig;
539
+ private localConfig;
321
540
  private embeddedServer;
322
541
  private tunnelHandle;
323
542
  constructor(options: PatterOptions | LocalOptions);
@@ -335,51 +554,6 @@ declare class Patter {
335
554
  }): Promise<PhoneNumber>;
336
555
  assignAgent(numberId: string, agentId: string): Promise<void>;
337
556
  listCalls(limit?: number): Promise<Call[]>;
338
- static deepgram: typeof deepgram;
339
- static whisper: typeof whisper;
340
- static elevenlabs: typeof elevenlabs;
341
- static openaiTts: typeof openaiTts;
342
- static cartesia: typeof cartesia;
343
- static rime: typeof rime;
344
- static lmnt: typeof lmnt;
345
- static guardrail(opts: {
346
- name: string;
347
- blockedTerms?: string[];
348
- check?: (text: string) => boolean;
349
- replacement?: string;
350
- }): Guardrail;
351
- /**
352
- * Create a tool definition for use with `agent({ tools: [...] })`.
353
- *
354
- * Either `handler` (a function) or `webhookUrl` must be provided.
355
- *
356
- * @param opts.name - Tool name (visible to the LLM).
357
- * @param opts.description - What the tool does (visible to the LLM).
358
- * @param opts.parameters - JSON Schema for tool arguments.
359
- * @param opts.handler - Async function called in-process when the LLM invokes the tool.
360
- * @param opts.webhookUrl - URL to POST to when the LLM invokes the tool.
361
- *
362
- * @example
363
- * ```ts
364
- * phone.agent({
365
- * systemPrompt: 'You are a pizza bot.',
366
- * tools: [
367
- * Patter.tool({
368
- * name: 'check_menu',
369
- * description: 'Check available menu items',
370
- * handler: async (args) => JSON.stringify({ items: ['margherita'] }),
371
- * }),
372
- * ],
373
- * });
374
- * ```
375
- */
376
- static tool(opts: {
377
- name: string;
378
- description?: string;
379
- parameters?: Record<string, unknown>;
380
- handler?: (args: Record<string, unknown>, context: Record<string, unknown>) => Promise<string>;
381
- webhookUrl?: string;
382
- }): ToolDefinition;
383
557
  private registerNumber;
384
558
  }
385
559
 
@@ -552,6 +726,34 @@ declare class ProvisionError extends PatterError {
552
726
  constructor(message: string);
553
727
  }
554
728
 
729
+ /**
730
+ * Deepgram STT config builder. Tune latency via ``endpointingMs`` /
731
+ * ``utteranceEndMs``. Internal only — public code should use ``DeepgramSTT``
732
+ * from ``getpatter/stt/deepgram``.
733
+ */
734
+ declare function deepgram(opts: {
735
+ apiKey: string;
736
+ language?: string;
737
+ model?: string;
738
+ endpointingMs?: number;
739
+ utteranceEndMs?: number | null;
740
+ smartFormat?: boolean;
741
+ interimResults?: boolean;
742
+ vadEvents?: boolean;
743
+ }): STTConfig;
744
+ declare function whisper(opts: {
745
+ apiKey: string;
746
+ language?: string;
747
+ }): STTConfig;
748
+ declare function elevenlabs(opts: {
749
+ apiKey: string;
750
+ voice?: string;
751
+ }): TTSConfig;
752
+ declare function openaiTts(opts: {
753
+ apiKey: string;
754
+ voice?: string;
755
+ }): TTSConfig;
756
+
555
757
  /**
556
758
  * Default provider pricing and merge utilities.
557
759
  *
@@ -753,151 +955,48 @@ declare class ElevenLabsConvAIAdapter {
753
955
  close(): void;
754
956
  }
755
957
 
756
- interface Transcript$4 {
757
- readonly text: string;
758
- readonly isFinal: boolean;
759
- readonly confidence: number;
760
- }
761
- type TranscriptCallback$4 = (transcript: Transcript$4) => void;
762
958
  /**
763
- * Optional tuning knobs for Deepgram live transcription.
959
+ * In-memory metrics store for the local dashboard.
764
960
  *
765
- * Mirrors Python's ``DeepgramSTT`` kwargs so callers can lower turn latency
766
- * without monkey-patching (BUG #13).
961
+ * Keeps the last `maxCalls` completed calls and tracks active calls.
962
+ * Supports SSE event subscribers for real-time updates.
767
963
  */
768
- interface DeepgramSTTOptions {
769
- /** Model name. Default ``nova-3``. */
770
- readonly model?: string;
771
- /** Audio encoding (``linear16`` | ``mulaw`` | etc). Default ``linear16``. */
772
- readonly encoding?: string;
773
- /** Sample rate in Hz. Default ``16000``. */
774
- readonly sampleRate?: number;
964
+
965
+ interface CallRecord {
966
+ call_id: string;
967
+ caller: string;
968
+ callee: string;
969
+ direction: string;
970
+ started_at: number;
971
+ ended_at?: number;
775
972
  /**
776
- * Voice-activity endpointing threshold in milliseconds.
777
- * Lower values reduce turn latency at the cost of more false-start cuts.
778
- * Default ``150``.
973
+ * Current lifecycle state: ``initiated`` (pre-registered), ``ringing``,
974
+ * ``in-progress``, ``completed``, ``no-answer``, ``busy``, ``failed``,
975
+ * ``canceled``, or ``webhook_error``.
779
976
  */
780
- readonly endpointingMs?: number;
977
+ status?: string;
978
+ transcript?: Array<{
979
+ role: string;
980
+ text: string;
981
+ timestamp: number;
982
+ }>;
983
+ turns?: unknown[];
984
+ metrics?: Record<string, unknown> | null;
985
+ [key: string]: unknown;
986
+ }
987
+ interface SSEEvent {
988
+ type: string;
989
+ data: Record<string, unknown>;
990
+ }
991
+ declare class MetricsStore extends EventEmitter {
992
+ private readonly maxCalls;
993
+ private calls;
994
+ private activeCalls;
781
995
  /**
782
- * End-of-utterance silence window in milliseconds. Deepgram enforces a
783
- * hard minimum of 1000 ms. Set to ``null`` to disable. Default ``1000``.
784
- */
785
- readonly utteranceEndMs?: number | null;
786
- /** Enable smart formatting (punctuation + numerals). Default ``true``. */
787
- readonly smartFormat?: boolean;
788
- /** Emit interim (non-final) transcripts. Default ``true``. */
789
- readonly interimResults?: boolean;
790
- /** Emit VAD events (``SpeechStarted`` / ``UtteranceEnd``). Default ``true``. */
791
- readonly vadEvents?: boolean;
792
- }
793
- declare class DeepgramSTT {
794
- private ws;
795
- private callbacks;
796
- /** Request ID from Deepgram — used to query actual cost post-call. */
797
- requestId: string;
798
- private readonly apiKey;
799
- private readonly language;
800
- private readonly model;
801
- private readonly encoding;
802
- private readonly sampleRate;
803
- private readonly endpointingMs;
804
- private readonly utteranceEndMs;
805
- private readonly smartFormat;
806
- private readonly interimResults;
807
- private readonly vadEvents;
808
- /**
809
- * New ergonomic constructor accepting an options object (mirrors Python kwargs).
810
- *
811
- * Also accepts the legacy positional form
812
- * ``(apiKey, language?, model?, encoding?, sampleRate?)`` for backward
813
- * compatibility with code that predated BUG #13.
814
- */
815
- constructor(apiKey: string, language?: string, model?: string, encoding?: string, sampleRate?: number, options?: DeepgramSTTOptions);
816
- constructor(apiKey: string, options: DeepgramSTTOptions & {
817
- language?: string;
818
- });
819
- /** Factory for Twilio calls — mulaw 8 kHz. Forwards tuning options through. */
820
- static forTwilio(apiKey: string, language?: string, model?: string, options?: DeepgramSTTOptions): DeepgramSTT;
821
- connect(): Promise<void>;
822
- sendAudio(audio: Buffer): void;
823
- onTranscript(callback: TranscriptCallback$4): void;
824
- close(): void;
825
- }
826
-
827
- /**
828
- * OpenAI Whisper STT adapter for the Patter SDK pipeline mode.
829
- *
830
- * Buffers incoming PCM16 audio and periodically sends it to the
831
- * OpenAI Whisper transcription API as a WAV file.
832
- */
833
- interface Transcript$3 {
834
- readonly text: string;
835
- readonly isFinal: boolean;
836
- readonly confidence: number;
837
- }
838
- type TranscriptCallback$3 = (transcript: Transcript$3) => void;
839
- declare class WhisperSTT {
840
- private readonly apiKey;
841
- private readonly model;
842
- private readonly language;
843
- private readonly bufferSize;
844
- private buffer;
845
- private callbacks;
846
- private running;
847
- private pendingTranscriptions;
848
- constructor(apiKey: string, model?: string, language?: string, bufferSize?: number);
849
- /** Factory for Twilio calls — mulaw 8 kHz is transcoded upstream, so we still receive PCM 16-bit. */
850
- static forTwilio(apiKey: string, language?: string, model?: string): WhisperSTT;
851
- connect(): Promise<void>;
852
- sendAudio(audio: Buffer): void;
853
- private trackTranscription;
854
- onTranscript(callback: TranscriptCallback$3): void;
855
- close(): Promise<void>;
856
- private transcribeBuffer;
857
- }
858
-
859
- /**
860
- * In-memory metrics store for the local dashboard.
861
- *
862
- * Keeps the last `maxCalls` completed calls and tracks active calls.
863
- * Supports SSE event subscribers for real-time updates.
864
- */
865
-
866
- interface CallRecord {
867
- call_id: string;
868
- caller: string;
869
- callee: string;
870
- direction: string;
871
- started_at: number;
872
- ended_at?: number;
873
- /**
874
- * Current lifecycle state: ``initiated`` (pre-registered), ``ringing``,
875
- * ``in-progress``, ``completed``, ``no-answer``, ``busy``, ``failed``,
876
- * ``canceled``, or ``webhook_error``.
877
- */
878
- status?: string;
879
- transcript?: Array<{
880
- role: string;
881
- text: string;
882
- timestamp: number;
883
- }>;
884
- turns?: unknown[];
885
- metrics?: Record<string, unknown> | null;
886
- [key: string]: unknown;
887
- }
888
- interface SSEEvent {
889
- type: string;
890
- data: Record<string, unknown>;
891
- }
892
- declare class MetricsStore extends EventEmitter {
893
- private readonly maxCalls;
894
- private calls;
895
- private activeCalls;
896
- /**
897
- * Accepts either a numeric ``maxCalls`` (legacy positional — matches the
898
- * original TS API) or an options object ``{ maxCalls }`` to align with the
899
- * Python SDK's keyword-argument style. Plain literals also work:
900
- * ``new MetricsStore()`` / ``new MetricsStore(100)`` / ``new MetricsStore({ maxCalls: 100 })``.
996
+ * Accepts either a numeric ``maxCalls`` (legacy positional — matches the
997
+ * original TS API) or an options object ``{ maxCalls }`` to align with the
998
+ * Python SDK's keyword-argument style. Plain literals also work:
999
+ * ``new MetricsStore()`` / ``new MetricsStore(100)`` / ``new MetricsStore({ maxCalls: 100 })``.
901
1000
  */
902
1001
  constructor(maxCallsOrOpts?: number | {
903
1002
  maxCalls?: number;
@@ -1358,13 +1457,13 @@ declare function scheduleInterval(intervalOrOpts: number | {
1358
1457
  * `speechmatics` extra; TypeScript users need to wait for an official
1359
1458
  * upstream SDK before this adapter can land without a WS-handshake reimpl.
1360
1459
  */
1361
- interface Transcript$2 {
1460
+ interface Transcript$4 {
1362
1461
  readonly text: string;
1363
1462
  readonly isFinal: boolean;
1364
1463
  readonly confidence: number;
1365
1464
  }
1366
- type TranscriptCallback$2 = (transcript: Transcript$2) => void;
1367
- interface SonioxSTTOptions {
1465
+ type TranscriptCallback$4 = (transcript: Transcript$4) => void;
1466
+ interface SonioxSTTOptions$1 {
1368
1467
  model?: string;
1369
1468
  languageHints?: string[];
1370
1469
  languageHintsStrict?: boolean;
@@ -1392,7 +1491,7 @@ declare class SonioxSTT {
1392
1491
  private readonly maxEndpointDelayMs;
1393
1492
  private readonly clientReferenceId?;
1394
1493
  private readonly baseUrl;
1395
- constructor(apiKey: string, options?: SonioxSTTOptions);
1494
+ constructor(apiKey: string, options?: SonioxSTTOptions$1);
1396
1495
  /** Factory for Twilio-style 8 kHz linear PCM. */
1397
1496
  static forTwilio(apiKey: string, languageHints?: string[]): SonioxSTT;
1398
1497
  private buildConfig;
@@ -1401,7 +1500,7 @@ declare class SonioxSTT {
1401
1500
  private handleMessage;
1402
1501
  private emit;
1403
1502
  sendAudio(audio: Buffer): void;
1404
- onTranscript(callback: TranscriptCallback$2): void;
1503
+ onTranscript(callback: TranscriptCallback$4): void;
1405
1504
  close(): void;
1406
1505
  }
1407
1506
 
@@ -1416,15 +1515,15 @@ declare class SonioxSTT {
1416
1515
  * Source: livekit-plugins/livekit-plugins-assemblyai/livekit/plugins/assemblyai/stt.py
1417
1516
  * Upstream ref SHA: 78a66bcf79c5cea82989401c408f1dff4b961a5b
1418
1517
  */
1419
- interface Transcript$1 {
1518
+ interface Transcript$3 {
1420
1519
  readonly text: string;
1421
1520
  readonly isFinal: boolean;
1422
1521
  readonly confidence: number;
1423
1522
  }
1424
- type TranscriptCallback$1 = (transcript: Transcript$1) => void;
1523
+ type TranscriptCallback$3 = (transcript: Transcript$3) => void;
1425
1524
  type AssemblyAIEncoding = 'pcm_s16le' | 'pcm_mulaw';
1426
1525
  type AssemblyAIModel = 'universal-streaming-english' | 'universal-streaming-multilingual' | 'u3-rt-pro';
1427
- interface AssemblyAISTTOptions {
1526
+ interface AssemblyAISTTOptions$1 {
1428
1527
  /** One of the AssemblyAI speech models. */
1429
1528
  readonly model?: AssemblyAIModel;
1430
1529
  /** PCM encoding: 16-bit little-endian (default) or G.711 mu-law for telephony. */
@@ -1465,7 +1564,7 @@ declare class AssemblyAISTT {
1465
1564
  sessionId: string;
1466
1565
  /** Unix timestamp when the AssemblyAI session expires. */
1467
1566
  expiresAt: number;
1468
- constructor(apiKey: string, options?: AssemblyAISTTOptions);
1567
+ constructor(apiKey: string, options?: AssemblyAISTTOptions$1);
1469
1568
  /** Factory for Twilio calls — mulaw 8 kHz. */
1470
1569
  static forTwilio(apiKey: string, model?: AssemblyAIModel): AssemblyAISTT;
1471
1570
  private buildUrl;
@@ -1473,7 +1572,7 @@ declare class AssemblyAISTT {
1473
1572
  private handleEvent;
1474
1573
  private emit;
1475
1574
  sendAudio(audio: Buffer): void;
1476
- onTranscript(callback: TranscriptCallback$1): void;
1575
+ onTranscript(callback: TranscriptCallback$3): void;
1477
1576
  close(): void;
1478
1577
  }
1479
1578
 
@@ -1488,15 +1587,15 @@ declare class AssemblyAISTT {
1488
1587
  * Source: livekit-plugins/livekit-plugins-cartesia/livekit/plugins/cartesia/stt.py
1489
1588
  * Upstream ref SHA: 78a66bcf79c5cea82989401c408f1dff4b961a5b
1490
1589
  */
1491
- interface Transcript {
1590
+ interface Transcript$2 {
1492
1591
  readonly text: string;
1493
1592
  readonly isFinal: boolean;
1494
1593
  readonly confidence: number;
1495
1594
  }
1496
- type TranscriptCallback = (transcript: Transcript) => void;
1595
+ type TranscriptCallback$2 = (transcript: Transcript$2) => void;
1497
1596
  /** Cartesia STT currently only accepts 16-bit PCM little-endian. */
1498
1597
  type CartesiaEncoding = 'pcm_s16le';
1499
- interface CartesiaSTTOptions {
1598
+ interface CartesiaSTTOptions$1 {
1500
1599
  /** Cartesia STT model. Currently only `"ink-whisper"`. */
1501
1600
  readonly model?: string;
1502
1601
  /** BCP-47 language code. */
@@ -1516,16 +1615,291 @@ declare class CartesiaSTT {
1516
1615
  private keepaliveTimer;
1517
1616
  /** Cartesia request id — set from the server transcript events. */
1518
1617
  requestId: string;
1519
- constructor(apiKey: string, options?: CartesiaSTTOptions);
1618
+ constructor(apiKey: string, options?: CartesiaSTTOptions$1);
1520
1619
  private buildWsUrl;
1521
1620
  connect(): Promise<void>;
1522
1621
  private handleEvent;
1523
1622
  private emit;
1524
1623
  sendAudio(audio: Buffer): void;
1525
- onTranscript(callback: TranscriptCallback): void;
1624
+ onTranscript(callback: TranscriptCallback$2): void;
1526
1625
  close(): void;
1527
1626
  }
1528
1627
 
1628
+ type LMNTAudioFormat = 'aac' | 'mp3' | 'mulaw' | 'raw' | 'wav';
1629
+ type LMNTModel = 'blizzard' | 'aurora';
1630
+ type LMNTSampleRate = 8000 | 16000 | 24000;
1631
+ interface LMNTTTSOptions$1 {
1632
+ model?: LMNTModel;
1633
+ voice?: string;
1634
+ language?: string;
1635
+ format?: LMNTAudioFormat;
1636
+ sampleRate?: LMNTSampleRate;
1637
+ temperature?: number;
1638
+ topP?: number;
1639
+ baseUrl?: string;
1640
+ }
1641
+ declare class LMNTTTS {
1642
+ private readonly apiKey;
1643
+ private readonly model;
1644
+ private readonly voice;
1645
+ private readonly language;
1646
+ private readonly format;
1647
+ private readonly sampleRate;
1648
+ private readonly temperature;
1649
+ private readonly topP;
1650
+ private readonly baseUrl;
1651
+ constructor(apiKey: string, opts?: LMNTTTSOptions$1);
1652
+ private buildPayload;
1653
+ synthesize(text: string): Promise<Buffer>;
1654
+ /** Yield audio chunks as they arrive — raw PCM_S16LE by default. */
1655
+ synthesizeStream(text: string): AsyncGenerator<Buffer>;
1656
+ }
1657
+
1658
+ interface Transcript$1 {
1659
+ readonly text: string;
1660
+ readonly isFinal: boolean;
1661
+ readonly confidence: number;
1662
+ }
1663
+ type TranscriptCallback$1 = (transcript: Transcript$1) => void;
1664
+ /**
1665
+ * Optional tuning knobs for Deepgram live transcription.
1666
+ *
1667
+ * Mirrors Python's ``DeepgramSTT`` kwargs so callers can lower turn latency
1668
+ * without monkey-patching (BUG #13).
1669
+ */
1670
+ interface DeepgramSTTOptions$1 {
1671
+ /** Model name. Default ``nova-3``. */
1672
+ readonly model?: string;
1673
+ /** Audio encoding (``linear16`` | ``mulaw`` | etc). Default ``linear16``. */
1674
+ readonly encoding?: string;
1675
+ /** Sample rate in Hz. Default ``16000``. */
1676
+ readonly sampleRate?: number;
1677
+ /**
1678
+ * Voice-activity endpointing threshold in milliseconds.
1679
+ * Lower values reduce turn latency at the cost of more false-start cuts.
1680
+ * Default ``150``.
1681
+ */
1682
+ readonly endpointingMs?: number;
1683
+ /**
1684
+ * End-of-utterance silence window in milliseconds. Deepgram enforces a
1685
+ * hard minimum of 1000 ms. Set to ``null`` to disable. Default ``1000``.
1686
+ */
1687
+ readonly utteranceEndMs?: number | null;
1688
+ /** Enable smart formatting (punctuation + numerals). Default ``true``. */
1689
+ readonly smartFormat?: boolean;
1690
+ /** Emit interim (non-final) transcripts. Default ``true``. */
1691
+ readonly interimResults?: boolean;
1692
+ /** Emit VAD events (``SpeechStarted`` / ``UtteranceEnd``). Default ``true``. */
1693
+ readonly vadEvents?: boolean;
1694
+ }
1695
+ declare class DeepgramSTT {
1696
+ private ws;
1697
+ private callbacks;
1698
+ /** Request ID from Deepgram — used to query actual cost post-call. */
1699
+ requestId: string;
1700
+ private readonly apiKey;
1701
+ private readonly language;
1702
+ private readonly model;
1703
+ private readonly encoding;
1704
+ private readonly sampleRate;
1705
+ private readonly endpointingMs;
1706
+ private readonly utteranceEndMs;
1707
+ private readonly smartFormat;
1708
+ private readonly interimResults;
1709
+ private readonly vadEvents;
1710
+ /**
1711
+ * New ergonomic constructor accepting an options object (mirrors Python kwargs).
1712
+ *
1713
+ * Also accepts the legacy positional form
1714
+ * ``(apiKey, language?, model?, encoding?, sampleRate?)`` for backward
1715
+ * compatibility with code that predated BUG #13.
1716
+ */
1717
+ constructor(apiKey: string, language?: string, model?: string, encoding?: string, sampleRate?: number, options?: DeepgramSTTOptions$1);
1718
+ constructor(apiKey: string, options: DeepgramSTTOptions$1 & {
1719
+ language?: string;
1720
+ });
1721
+ /** Factory for Twilio calls — mulaw 8 kHz. Forwards tuning options through. */
1722
+ static forTwilio(apiKey: string, language?: string, model?: string, options?: DeepgramSTTOptions$1): DeepgramSTT;
1723
+ connect(): Promise<void>;
1724
+ sendAudio(audio: Buffer): void;
1725
+ onTranscript(callback: TranscriptCallback$1): void;
1726
+ close(): void;
1727
+ }
1728
+
1729
+ /** Deepgram streaming STT for Patter pipeline mode. */
1730
+
1731
+ interface DeepgramSTTOptions {
1732
+ /** API key. Falls back to DEEPGRAM_API_KEY env var when omitted. */
1733
+ apiKey?: string;
1734
+ language?: string;
1735
+ model?: string;
1736
+ encoding?: string;
1737
+ sampleRate?: number;
1738
+ endpointingMs?: number;
1739
+ utteranceEndMs?: number | null;
1740
+ smartFormat?: boolean;
1741
+ interimResults?: boolean;
1742
+ vadEvents?: boolean;
1743
+ }
1744
+ /**
1745
+ * Deepgram streaming STT.
1746
+ *
1747
+ * @example
1748
+ * ```ts
1749
+ * import * as deepgram from "getpatter/stt/deepgram";
1750
+ * const stt = new deepgram.STT(); // reads DEEPGRAM_API_KEY
1751
+ * const stt = new deepgram.STT({ apiKey: "dg_...", endpointingMs: 80 });
1752
+ * ```
1753
+ */
1754
+ declare class STT$4 extends DeepgramSTT {
1755
+ constructor(opts?: DeepgramSTTOptions);
1756
+ }
1757
+
1758
+ /**
1759
+ * OpenAI Whisper STT adapter for the Patter SDK pipeline mode.
1760
+ *
1761
+ * Buffers incoming PCM16 audio and periodically sends it to the
1762
+ * OpenAI Whisper transcription API as a WAV file.
1763
+ */
1764
+ interface Transcript {
1765
+ readonly text: string;
1766
+ readonly isFinal: boolean;
1767
+ readonly confidence: number;
1768
+ }
1769
+ type TranscriptCallback = (transcript: Transcript) => void;
1770
+ declare class WhisperSTT {
1771
+ private readonly apiKey;
1772
+ private readonly model;
1773
+ private readonly language;
1774
+ private readonly bufferSize;
1775
+ private buffer;
1776
+ private callbacks;
1777
+ private running;
1778
+ private pendingTranscriptions;
1779
+ constructor(apiKey: string, model?: string, language?: string, bufferSize?: number);
1780
+ /** Factory for Twilio calls — mulaw 8 kHz is transcoded upstream, so we still receive PCM 16-bit. */
1781
+ static forTwilio(apiKey: string, language?: string, model?: string): WhisperSTT;
1782
+ connect(): Promise<void>;
1783
+ sendAudio(audio: Buffer): void;
1784
+ private trackTranscription;
1785
+ onTranscript(callback: TranscriptCallback): void;
1786
+ close(): Promise<void>;
1787
+ private transcribeBuffer;
1788
+ }
1789
+
1790
+ /** OpenAI Whisper STT for Patter pipeline mode. */
1791
+
1792
+ interface WhisperSTTOptions {
1793
+ /** API key. Falls back to OPENAI_API_KEY env var when omitted. */
1794
+ apiKey?: string;
1795
+ model?: string;
1796
+ language?: string;
1797
+ bufferSize?: number;
1798
+ }
1799
+ /**
1800
+ * OpenAI Whisper STT.
1801
+ *
1802
+ * @example
1803
+ * ```ts
1804
+ * import * as whisper from "getpatter/stt/whisper";
1805
+ * const stt = new whisper.STT(); // reads OPENAI_API_KEY
1806
+ * const stt = new whisper.STT({ apiKey: "sk-...", language: "en" });
1807
+ * ```
1808
+ */
1809
+ declare class STT$3 extends WhisperSTT {
1810
+ constructor(opts?: WhisperSTTOptions);
1811
+ }
1812
+
1813
+ /** Cartesia streaming STT for Patter pipeline mode. */
1814
+
1815
+ interface CartesiaSTTOptions {
1816
+ /** API key. Falls back to CARTESIA_API_KEY env var when omitted. */
1817
+ apiKey?: string;
1818
+ model?: string;
1819
+ language?: string;
1820
+ encoding?: CartesiaEncoding;
1821
+ sampleRate?: number;
1822
+ baseUrl?: string;
1823
+ }
1824
+ /**
1825
+ * Cartesia streaming STT (ink-whisper).
1826
+ *
1827
+ * @example
1828
+ * ```ts
1829
+ * import * as cartesia from "getpatter/stt/cartesia";
1830
+ * const stt = new cartesia.STT(); // reads CARTESIA_API_KEY
1831
+ * const stt = new cartesia.STT({ apiKey: "..." });
1832
+ * ```
1833
+ */
1834
+ declare class STT$2 extends CartesiaSTT {
1835
+ constructor(opts?: CartesiaSTTOptions);
1836
+ }
1837
+
1838
+ /** Soniox streaming STT for Patter pipeline mode. */
1839
+
1840
+ interface SonioxSTTOptions {
1841
+ /** API key. Falls back to SONIOX_API_KEY env var when omitted. */
1842
+ apiKey?: string;
1843
+ model?: string;
1844
+ languageHints?: string[];
1845
+ languageHintsStrict?: boolean;
1846
+ sampleRate?: number;
1847
+ numChannels?: number;
1848
+ enableSpeakerDiarization?: boolean;
1849
+ enableLanguageIdentification?: boolean;
1850
+ maxEndpointDelayMs?: number;
1851
+ clientReferenceId?: string;
1852
+ baseUrl?: string;
1853
+ }
1854
+ /**
1855
+ * Soniox streaming STT.
1856
+ *
1857
+ * @example
1858
+ * ```ts
1859
+ * import * as soniox from "getpatter/stt/soniox";
1860
+ * const stt = new soniox.STT(); // reads SONIOX_API_KEY
1861
+ * const stt = new soniox.STT({ apiKey: "..." });
1862
+ * ```
1863
+ */
1864
+ declare class STT$1 extends SonioxSTT {
1865
+ constructor(opts?: SonioxSTTOptions);
1866
+ }
1867
+
1868
+ /** AssemblyAI Universal Streaming STT for Patter pipeline mode. */
1869
+
1870
+ interface AssemblyAISTTOptions {
1871
+ /** API key. Falls back to ASSEMBLYAI_API_KEY env var when omitted. */
1872
+ apiKey?: string;
1873
+ model?: AssemblyAIModel;
1874
+ encoding?: AssemblyAIEncoding;
1875
+ sampleRate?: number;
1876
+ baseUrl?: string;
1877
+ languageDetection?: boolean;
1878
+ endOfTurnConfidenceThreshold?: number;
1879
+ minTurnSilence?: number;
1880
+ maxTurnSilence?: number;
1881
+ formatTurns?: boolean;
1882
+ keytermsPrompt?: readonly string[];
1883
+ prompt?: string;
1884
+ vadThreshold?: number;
1885
+ speakerLabels?: boolean;
1886
+ maxSpeakers?: number;
1887
+ domain?: string;
1888
+ }
1889
+ /**
1890
+ * AssemblyAI Universal Streaming STT.
1891
+ *
1892
+ * @example
1893
+ * ```ts
1894
+ * import * as assemblyai from "getpatter/stt/assemblyai";
1895
+ * const stt = new assemblyai.STT(); // reads ASSEMBLYAI_API_KEY
1896
+ * const stt = new assemblyai.STT({ apiKey: "..." });
1897
+ * ```
1898
+ */
1899
+ declare class STT extends AssemblyAISTT {
1900
+ constructor(opts?: AssemblyAISTTOptions);
1901
+ }
1902
+
1529
1903
  declare class ElevenLabsTTS {
1530
1904
  private readonly apiKey;
1531
1905
  private readonly modelId;
@@ -1547,6 +1921,29 @@ declare class ElevenLabsTTS {
1547
1921
  synthesizeStream(text: string): AsyncGenerator<Buffer>;
1548
1922
  }
1549
1923
 
1924
+ /** ElevenLabs TTS for Patter pipeline mode. */
1925
+
1926
+ interface ElevenLabsTTSOptions {
1927
+ /** API key. Falls back to ELEVENLABS_API_KEY env var when omitted. */
1928
+ apiKey?: string;
1929
+ voiceId?: string;
1930
+ modelId?: string;
1931
+ outputFormat?: string;
1932
+ }
1933
+ /**
1934
+ * ElevenLabs TTS.
1935
+ *
1936
+ * @example
1937
+ * ```ts
1938
+ * import * as elevenlabs from "getpatter/tts/elevenlabs";
1939
+ * const tts = new elevenlabs.TTS(); // reads ELEVENLABS_API_KEY
1940
+ * const tts = new elevenlabs.TTS({ apiKey: "...", voiceId: "rachel" });
1941
+ * ```
1942
+ */
1943
+ declare class TTS$4 extends ElevenLabsTTS {
1944
+ constructor(opts?: ElevenLabsTTSOptions);
1945
+ }
1946
+
1550
1947
  declare class OpenAITTS {
1551
1948
  private readonly apiKey;
1552
1949
  private readonly voice;
@@ -1582,7 +1979,29 @@ declare class OpenAITTS {
1582
1979
  static resample24kTo16k(audio: Buffer): Buffer;
1583
1980
  }
1584
1981
 
1585
- interface CartesiaTTSOptions {
1982
+ /** OpenAI TTS for Patter pipeline mode. */
1983
+
1984
+ interface OpenAITTSOptions {
1985
+ /** API key. Falls back to OPENAI_API_KEY env var when omitted. */
1986
+ apiKey?: string;
1987
+ voice?: string;
1988
+ model?: string;
1989
+ }
1990
+ /**
1991
+ * OpenAI TTS.
1992
+ *
1993
+ * @example
1994
+ * ```ts
1995
+ * import * as openai from "getpatter/tts/openai";
1996
+ * const tts = new openai.TTS(); // reads OPENAI_API_KEY
1997
+ * const tts = new openai.TTS({ apiKey: "sk-...", voice: "alloy" });
1998
+ * ```
1999
+ */
2000
+ declare class TTS$3 extends OpenAITTS {
2001
+ constructor(opts?: OpenAITTSOptions);
2002
+ }
2003
+
2004
+ interface CartesiaTTSOptions$1 {
1586
2005
  model?: string;
1587
2006
  voice?: string;
1588
2007
  language?: string;
@@ -1604,7 +2023,7 @@ declare class CartesiaTTS {
1604
2023
  private readonly volume?;
1605
2024
  private readonly baseUrl;
1606
2025
  private readonly apiVersion;
1607
- constructor(apiKey: string, opts?: CartesiaTTSOptions);
2026
+ constructor(apiKey: string, opts?: CartesiaTTSOptions$1);
1608
2027
  /** Build the JSON payload for the Cartesia bytes endpoint. */
1609
2028
  private buildPayload;
1610
2029
  /** Synthesize text and return the concatenated audio buffer. */
@@ -1616,7 +2035,36 @@ declare class CartesiaTTS {
1616
2035
  synthesizeStream(text: string): AsyncGenerator<Buffer>;
1617
2036
  }
1618
2037
 
1619
- interface RimeTTSOptions {
2038
+ /** Cartesia TTS for Patter pipeline mode. */
2039
+
2040
+ interface CartesiaTTSOptions {
2041
+ /** API key. Falls back to CARTESIA_API_KEY env var when omitted. */
2042
+ apiKey?: string;
2043
+ model?: string;
2044
+ voice?: string;
2045
+ language?: string;
2046
+ sampleRate?: number;
2047
+ speed?: string | number;
2048
+ emotion?: string | string[];
2049
+ volume?: number;
2050
+ baseUrl?: string;
2051
+ apiVersion?: string;
2052
+ }
2053
+ /**
2054
+ * Cartesia TTS (sonic-2).
2055
+ *
2056
+ * @example
2057
+ * ```ts
2058
+ * import * as cartesia from "getpatter/tts/cartesia";
2059
+ * const tts = new cartesia.TTS(); // reads CARTESIA_API_KEY
2060
+ * const tts = new cartesia.TTS({ apiKey: "..." });
2061
+ * ```
2062
+ */
2063
+ declare class TTS$2 extends CartesiaTTS {
2064
+ constructor(opts?: CartesiaTTSOptions);
2065
+ }
2066
+
2067
+ interface RimeTTSOptions$1 {
1620
2068
  model?: string;
1621
2069
  speaker?: string;
1622
2070
  lang?: string;
@@ -1647,7 +2095,7 @@ declare class RimeTTS {
1647
2095
  private readonly phonemizeBetweenBrackets?;
1648
2096
  private readonly baseUrl;
1649
2097
  private readonly totalTimeoutMs;
1650
- constructor(apiKey: string, opts?: RimeTTSOptions);
2098
+ constructor(apiKey: string, opts?: RimeTTSOptions$1);
1651
2099
  private buildPayload;
1652
2100
  synthesize(text: string): Promise<Buffer>;
1653
2101
  /**
@@ -1657,10 +2105,44 @@ declare class RimeTTS {
1657
2105
  synthesizeStream(text: string): AsyncGenerator<Buffer>;
1658
2106
  }
1659
2107
 
1660
- type LMNTAudioFormat = 'aac' | 'mp3' | 'mulaw' | 'raw' | 'wav';
1661
- type LMNTModel = 'blizzard' | 'aurora';
1662
- type LMNTSampleRate = 8000 | 16000 | 24000;
2108
+ /** Rime TTS for Patter pipeline mode. */
2109
+
2110
+ interface RimeTTSOptions {
2111
+ /** API key. Falls back to RIME_API_KEY env var when omitted. */
2112
+ apiKey?: string;
2113
+ model?: string;
2114
+ speaker?: string;
2115
+ lang?: string;
2116
+ sampleRate?: number;
2117
+ repetitionPenalty?: number;
2118
+ temperature?: number;
2119
+ topP?: number;
2120
+ maxTokens?: number;
2121
+ speedAlpha?: number;
2122
+ reduceLatency?: boolean;
2123
+ pauseBetweenBrackets?: boolean;
2124
+ phonemizeBetweenBrackets?: boolean;
2125
+ baseUrl?: string;
2126
+ }
2127
+ /**
2128
+ * Rime TTS (Arcana or Mist models).
2129
+ *
2130
+ * @example
2131
+ * ```ts
2132
+ * import * as rime from "getpatter/tts/rime";
2133
+ * const tts = new rime.TTS(); // reads RIME_API_KEY
2134
+ * const tts = new rime.TTS({ apiKey: "...", speaker: "astra" });
2135
+ * ```
2136
+ */
2137
+ declare class TTS$1 extends RimeTTS {
2138
+ constructor(opts?: RimeTTSOptions);
2139
+ }
2140
+
2141
+ /** LMNT TTS for Patter pipeline mode. */
2142
+
1663
2143
  interface LMNTTTSOptions {
2144
+ /** API key. Falls back to LMNT_API_KEY env var when omitted. */
2145
+ apiKey?: string;
1664
2146
  model?: LMNTModel;
1665
2147
  voice?: string;
1666
2148
  language?: string;
@@ -1670,21 +2152,18 @@ interface LMNTTTSOptions {
1670
2152
  topP?: number;
1671
2153
  baseUrl?: string;
1672
2154
  }
1673
- declare class LMNTTTS {
1674
- private readonly apiKey;
1675
- private readonly model;
1676
- private readonly voice;
1677
- private readonly language;
1678
- private readonly format;
1679
- private readonly sampleRate;
1680
- private readonly temperature;
1681
- private readonly topP;
1682
- private readonly baseUrl;
1683
- constructor(apiKey: string, opts?: LMNTTTSOptions);
1684
- private buildPayload;
1685
- synthesize(text: string): Promise<Buffer>;
1686
- /** Yield audio chunks as they arrive — raw PCM_S16LE by default. */
1687
- synthesizeStream(text: string): AsyncGenerator<Buffer>;
2155
+ /**
2156
+ * LMNT TTS (blizzard/aurora).
2157
+ *
2158
+ * @example
2159
+ * ```ts
2160
+ * import * as lmnt from "getpatter/tts/lmnt";
2161
+ * const tts = new lmnt.TTS(); // reads LMNT_API_KEY
2162
+ * const tts = new lmnt.TTS({ apiKey: "...", voice: "leah" });
2163
+ * ```
2164
+ */
2165
+ declare class TTS extends LMNTTTS {
2166
+ constructor(opts?: LMNTTTSOptions);
1688
2167
  }
1689
2168
 
1690
2169
  /**
@@ -2048,4 +2527,4 @@ declare class BackgroundAudioPlayer implements BackgroundAudioPlayer$1 {
2048
2527
  private resampleTo;
2049
2528
  }
2050
2529
 
2051
- export { type Agent, type AgentOptions, AllProvidersFailedError, type AnthropicConversion, type AnthropicMessage, type AssemblyAIEncoding, type AssemblyAIModel, AssemblyAISTT, type AssemblyAISTTOptions, type AudioConfig, type AudioSource, AuthenticationError, type BackgroundAudioOptions, BackgroundAudioPlayer, BuiltinAudioClip, type BuiltinAudioClipName, type BuiltinPcmSource, type Call, type CallControl, type CallEventHandler, type CallMetrics, CallMetricsAccumulator, type CallOptions, type CallRecord, type CartesiaEncoding, CartesiaSTT, type CartesiaSTTOptions, CartesiaTTS, type CartesiaTTSOptions, ChatContext, type ChatMessage, type ChatRole, type ConnectOptions, type CostBreakdown, type CreateAgentOptions, DEFAULT_MIN_SENTENCE_LEN, DEFAULT_PRICING, DTMF_EVENTS, DeepgramSTT, type DefineToolInput, type DtmfEvent, ElevenLabsConvAIAdapter, ElevenLabsTTS, FallbackLLMProvider, type FallbackLLMProviderOptions, type FilePcmSource, GEMINI_DEFAULT_INPUT_SR, GEMINI_DEFAULT_OUTPUT_SR, GeminiLiveAdapter, type GeminiLiveEventHandler, type Guardrail, type HookContext, IVRActivity, type IVRActivityOptions, type IVRToolDefinition, type IncomingMessage, type JobCallback, type LLMChunk, LLMLoop, type LLMProvider, type LMNTAudioFormat, type LMNTModel, type LMNTSampleRate, LMNTTTS, type LMNTTTSOptions, type LatencyBreakdown, type LocalCallOptions, type LocalConfig, type LocalOptions, type Logger, type LoopCallback, type MessageHandler, MetricsStore, OpenAILLMProvider, type OpenAIMessage, OpenAIRealtimeAdapter, OpenAITTS, type ParamSpec, PartialStreamError, Patter, PatterConnectionError, PatterError, type PatterOptions, type PhoneNumber, PipelineHookExecutor, type PipelineHooks, type PipelineMessageHandler, type ProviderPricing, ProvisionError, type RawPcmSource, RemoteMessageHandler, RimeTTS, type RimeTTSOptions, type SSEEvent, type STTConfig, type ScheduleHandle, SentenceChunker, type ServeOptions, type SilenceCallback, SonioxSTT, type SonioxSTTOptions, type TTSConfig, TestSession, TfidfLoopDetector, type TfidfLoopDetectorOptions, type ToolDefinition, type TunnelHandle, type TurnMetrics, ULTRAVOX_DEFAULT_API_BASE, ULTRAVOX_DEFAULT_SR, type UltravoxEventHandler, UltravoxRealtimeAdapter, WhisperSTT, builtinClipPath, calculateRealtimeCost, calculateSttCost, calculateTelephonyCost, calculateTtsCost, callsToCsv, callsToJson, deepgram, defineTool, elevenlabs, filterEmoji, filterForTTS, filterMarkdown, formatDtmf, getLogger, isRemoteUrl, isWebSocketUrl, makeAuthMiddleware, mergePricing, mixPcm, mountApi, mountDashboard, mulawToPcm16, notifyDashboard, openaiTts, pcm16ToMulaw, resample16kTo8k, resample24kTo16k, resample8kTo16k, resamplePcm, scheduleCron, scheduleInterval, scheduleOnce, selectSoundFromList, setLogger, startTunnel, whisper };
2530
+ export { type Agent, type AgentOptions, AllProvidersFailedError, type AnthropicConversion, type AnthropicMessage, type AssemblyAIEncoding, type AssemblyAIModel, STT as AssemblyAISTT, type AssemblyAISTTOptions, type AudioConfig, type AudioSource, AuthenticationError, type BackgroundAudioOptions, BackgroundAudioPlayer, BuiltinAudioClip, type BuiltinAudioClipName, type BuiltinPcmSource, type Call, type CallControl, type CallEventHandler, type CallMetrics, CallMetricsAccumulator, type CallOptions, type CallRecord, type CartesiaEncoding, STT$2 as CartesiaSTT, type CartesiaSTTOptions, TTS$2 as CartesiaTTS, type CartesiaTTSOptions, ChatContext, type ChatMessage, type ChatRole, CloudflareTunnel, type ConnectOptions, type CostBreakdown, type CreateAgentOptions, DEFAULT_MIN_SENTENCE_LEN, DEFAULT_PRICING, DTMF_EVENTS, STT$4 as DeepgramSTT, type DeepgramSTTOptions, type DefineToolInput, type DtmfEvent, ConvAI as ElevenLabsConvAI, ElevenLabsConvAIAdapter, type ConvAIOptions as ElevenLabsConvAIOptions, TTS$4 as ElevenLabsTTS, type ElevenLabsTTSOptions, FallbackLLMProvider, type FallbackLLMProviderOptions, type FilePcmSource, GEMINI_DEFAULT_INPUT_SR, GEMINI_DEFAULT_OUTPUT_SR, GeminiLiveAdapter, type GeminiLiveEventHandler, Guardrail$1 as Guardrail, type GuardrailOptions, type HookContext, IVRActivity, type IVRActivityOptions, type IVRToolDefinition, type IncomingMessage, type JobCallback, type LLMChunk, LLMLoop, type LLMProvider, type LMNTAudioFormat, type LMNTModel, type LMNTSampleRate, TTS as LMNTTTS, type LMNTTTSOptions, type LatencyBreakdown, type LocalCallOptions, type LocalConfig, type LocalOptions, type Logger, type LoopCallback, type MessageHandler, MetricsStore, OpenAILLMProvider, type OpenAIMessage, Realtime as OpenAIRealtime, OpenAIRealtimeAdapter, type RealtimeOptions as OpenAIRealtimeOptions, TTS$3 as OpenAITTS, type OpenAITTSOptions, type ParamSpec, PartialStreamError, Patter, PatterConnectionError, PatterError, type PatterOptions, type PhoneNumber, PipelineHookExecutor, type PipelineHooks, type PipelineMessageHandler, type ProviderPricing, ProvisionError, type RawPcmSource, RemoteMessageHandler, TTS$1 as RimeTTS, type RimeTTSOptions, type SSEEvent, type STTConfig, type ScheduleHandle, SentenceChunker, type ServeOptions, type SilenceCallback, STT$1 as SonioxSTT, type SonioxSTTOptions$1 as SonioxSTTOptions, Static as StaticTunnel, type TTSConfig, Carrier as Telnyx, type TelnyxCarrierOptions, TestSession, TfidfLoopDetector, type TfidfLoopDetectorOptions, Tool, type ToolDefinition, type ToolHandler, type ToolOptions, type TunnelHandle, type TurnMetrics, Carrier$1 as Twilio, type TwilioCarrierOptions, ULTRAVOX_DEFAULT_API_BASE, ULTRAVOX_DEFAULT_SR, type UltravoxEventHandler, UltravoxRealtimeAdapter, STT$3 as WhisperSTT, type WhisperSTTOptions, builtinClipPath, calculateRealtimeCost, calculateSttCost, calculateTelephonyCost, calculateTtsCost, callsToCsv, callsToJson, deepgram, defineTool, elevenlabs, filterEmoji, filterForTTS, filterMarkdown, formatDtmf, getLogger, guardrail, isRemoteUrl, isWebSocketUrl, makeAuthMiddleware, mergePricing, mixPcm, mountApi, mountDashboard, mulawToPcm16, notifyDashboard, openaiTts, pcm16ToMulaw, resample16kTo8k, resample24kTo16k, resample8kTo16k, resamplePcm, scheduleCron, scheduleInterval, scheduleOnce, selectSoundFromList, setLogger, startTunnel, tool, whisper };