@teamlearners/clawops 0.1.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.
@@ -0,0 +1,821 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * MCP server configuration for stdio-based servers.
5
+ */
6
+ interface MCPServerStdio {
7
+ type: 'stdio';
8
+ /** Command to execute. */
9
+ command: string;
10
+ /** Command arguments. */
11
+ args?: string[];
12
+ /** Environment variables. */
13
+ env?: Record<string, string>;
14
+ [key: string]: unknown;
15
+ }
16
+ /**
17
+ * Create a stdio MCP server configuration.
18
+ */
19
+ declare function mcpServerStdio(options: {
20
+ command: string;
21
+ args?: string[];
22
+ env?: Record<string, string>;
23
+ }): MCPServerStdio;
24
+
25
+ /**
26
+ * MCP server configuration for HTTP-based servers.
27
+ */
28
+ interface MCPServerHTTP {
29
+ type: 'http';
30
+ /** Server URL. */
31
+ url: string;
32
+ /** Additional headers to send with requests. */
33
+ headers?: Record<string, string>;
34
+ [key: string]: unknown;
35
+ }
36
+ /**
37
+ * Create an HTTP MCP server configuration.
38
+ */
39
+ declare function mcpServerHTTP(options: {
40
+ url: string;
41
+ headers?: Record<string, string>;
42
+ }): MCPServerHTTP;
43
+
44
+ /**
45
+ * CallSession represents an active phone call and provides methods to
46
+ * send audio, hang up, and listen for lifecycle events.
47
+ */
48
+ type CallDirection = 'inbound' | 'outbound';
49
+ type CallStatus = 'ringing' | 'active' | 'ended';
50
+ type SessionEventType = 'ended' | 'dtmf' | 'speech';
51
+ interface SessionEvent {
52
+ type: SessionEventType;
53
+ data?: unknown;
54
+ }
55
+ type SessionEventHandler = (event: SessionEvent) => void | Promise<void>;
56
+ interface SendAudioFn {
57
+ (audio: Buffer): void;
58
+ }
59
+ interface ClearAudioFn {
60
+ (): void;
61
+ }
62
+ interface HangupFn {
63
+ (): void;
64
+ }
65
+ declare class CallSession {
66
+ readonly callId: string;
67
+ readonly fromNumber: string;
68
+ readonly toNumber: string;
69
+ readonly accountId: string;
70
+ readonly direction: CallDirection;
71
+ readonly startTime: Date;
72
+ readonly metadata: Record<string, unknown>;
73
+ private _status;
74
+ private _sendAudioFn;
75
+ private _clearAudioFn;
76
+ private _hangupFn;
77
+ private _handlers;
78
+ private _endedPromise;
79
+ private _resolveEnded;
80
+ constructor(options: {
81
+ callId: string;
82
+ fromNumber: string;
83
+ toNumber: string;
84
+ accountId: string;
85
+ direction: CallDirection;
86
+ metadata?: Record<string, unknown>;
87
+ });
88
+ get status(): CallStatus;
89
+ get duration(): number;
90
+ /** Bind transport functions (called internally by the agent). */
91
+ _bindTransport(send: SendAudioFn, clear: ClearAudioFn, hangup: HangupFn): void;
92
+ /** Send PCM16 or ulaw audio to the caller. */
93
+ sendAudio(audio: Buffer): void;
94
+ /** Clear any queued outbound audio. */
95
+ clearAudio(): void;
96
+ /** Hang up the call. */
97
+ hangup(): void;
98
+ /** Register an event handler. */
99
+ on(event: SessionEventType, handler: SessionEventHandler): void;
100
+ /** Wait for the call to end. */
101
+ wait(): Promise<void>;
102
+ /** Mark the session as ended (called internally). */
103
+ _markEnded(): void;
104
+ /** Emit an event to registered handlers. */
105
+ _emit(event: SessionEvent): void;
106
+ }
107
+
108
+ /**
109
+ * Tool registry for function-calling in voice agent pipelines.
110
+ * Uses Zod schemas for parameter validation.
111
+ */
112
+
113
+ interface FunctionTool {
114
+ name: string;
115
+ description: string;
116
+ parameters: Record<string, unknown>;
117
+ required: string[];
118
+ handler: (args: Record<string, unknown>) => unknown | Promise<unknown>;
119
+ }
120
+ interface OpenAIToolDefinition {
121
+ type: 'function';
122
+ function: {
123
+ name: string;
124
+ description: string;
125
+ parameters: {
126
+ type: 'object';
127
+ properties: Record<string, unknown>;
128
+ required: string[];
129
+ };
130
+ };
131
+ }
132
+ /**
133
+ * Decorator / identity function for marking a function as a tool handler.
134
+ * In TypeScript, this simply returns the function as-is. Use with ToolRegistry.register().
135
+ */
136
+ declare function functionTool<T extends (...args: unknown[]) => unknown>(fn: T): T;
137
+ declare class ToolRegistry {
138
+ private _tools;
139
+ private _mcpTools;
140
+ /** Register a function tool. */
141
+ register(tool: FunctionTool): void;
142
+ /** Register tools discovered from MCP servers. */
143
+ registerMcpTools(tools: FunctionTool[]): void;
144
+ /** Clear all MCP-registered tools. */
145
+ clearMcpTools(): void;
146
+ /**
147
+ * Create a fork (shallow copy) of this registry.
148
+ * Useful for per-session tool isolation.
149
+ */
150
+ fork(): ToolRegistry;
151
+ /** Check if a tool is registered. */
152
+ has(name: string): boolean;
153
+ /** Get a tool by name. */
154
+ get(name: string): FunctionTool | undefined;
155
+ /** Convert all registered tools to OpenAI function-calling format. */
156
+ toOpenAITools(): OpenAIToolDefinition[];
157
+ /** Call a tool by name with the given arguments. */
158
+ call(name: string, args: Record<string, unknown>): Promise<unknown>;
159
+ /** Get the number of registered tools (including MCP). */
160
+ get size(): number;
161
+ }
162
+ /**
163
+ * Helper to convert a Zod object schema into a JSON Schema properties + required list.
164
+ */
165
+ declare function zodToToolParams(schema: z.ZodObject<z.ZodRawShape>): {
166
+ parameters: Record<string, unknown>;
167
+ required: string[];
168
+ };
169
+
170
+ /**
171
+ * Base interfaces for the voice agent pipeline.
172
+ */
173
+
174
+ /** Speech recognition event. */
175
+ interface SpeechEvent {
176
+ type: 'interim' | 'final';
177
+ transcript: string;
178
+ }
179
+ /** Conversation message for LLM context. */
180
+ interface ConversationMessage {
181
+ role: 'system' | 'user' | 'assistant' | 'tool';
182
+ content: string;
183
+ name?: string;
184
+ tool_call_id?: string;
185
+ }
186
+ /** Tool call request from an LLM. */
187
+ interface ToolCallRequest {
188
+ id: string;
189
+ name: string;
190
+ arguments: string;
191
+ }
192
+ /** LLM response chunk (for streaming). */
193
+ interface LLMChunk {
194
+ type: 'text' | 'tool_call' | 'done';
195
+ text?: string;
196
+ toolCall?: ToolCallRequest;
197
+ }
198
+ /**
199
+ * Session interface for realtime (speech-to-speech) providers.
200
+ * Implementations: OpenAIRealtime, GeminiRealtime
201
+ */
202
+ interface Session {
203
+ /** Start the realtime session with the call session and tools. */
204
+ start(callSession: CallSession, tools?: ToolRegistry): Promise<void>;
205
+ /** Feed raw audio into the session. */
206
+ feedAudio(audio: Buffer): void;
207
+ /** Stop the session. */
208
+ stop(): Promise<void>;
209
+ }
210
+ /**
211
+ * Speech-to-Text provider interface.
212
+ */
213
+ interface STT {
214
+ /**
215
+ * Transcribe audio. Returns an async generator of speech events.
216
+ * The generator yields interim results and a final result.
217
+ */
218
+ transcribe(audioStream: AsyncIterable<Buffer>, options?: {
219
+ language?: string;
220
+ sampleRate?: number;
221
+ }): AsyncGenerator<SpeechEvent>;
222
+ }
223
+ /**
224
+ * LLM (Large Language Model) provider interface.
225
+ */
226
+ interface LLM {
227
+ /**
228
+ * Generate a response from the LLM.
229
+ * Returns an async generator of response chunks.
230
+ */
231
+ generate(messages: ConversationMessage[], options?: {
232
+ tools?: ToolRegistry;
233
+ temperature?: number;
234
+ maxTokens?: number;
235
+ }): AsyncGenerator<LLMChunk>;
236
+ }
237
+ /**
238
+ * Text-to-Speech provider interface.
239
+ */
240
+ interface TTS {
241
+ /**
242
+ * Synthesize text to audio.
243
+ * Returns an async generator of PCM16 audio chunks.
244
+ */
245
+ synthesize(text: string | AsyncIterable<string>, options?: {
246
+ voice?: string;
247
+ sampleRate?: number;
248
+ }): AsyncGenerator<Buffer>;
249
+ }
250
+
251
+ /**
252
+ * Tracing configuration for OpenTelemetry integration.
253
+ */
254
+ interface TracingConfig {
255
+ /** Whether tracing is enabled. Default: false */
256
+ enabled: boolean;
257
+ /** Service name for traces. Default: 'clawops-agent' */
258
+ serviceName?: string;
259
+ /**
260
+ * Optional TracerProvider instance from @opentelemetry/api.
261
+ * If not provided, the global tracer provider will be used.
262
+ */
263
+ tracerProvider?: unknown;
264
+ }
265
+ /** Get the current tracing configuration. */
266
+ declare function getTracingConfig(): TracingConfig;
267
+ /** Set the tracing configuration. */
268
+ declare function setTracingConfig(config: Partial<TracingConfig>): void;
269
+ /** Reset tracing configuration to defaults. */
270
+ declare function resetTracingConfig(): void;
271
+
272
+ /**
273
+ * ClawOpsAgent - main agent class for handling voice calls.
274
+ */
275
+
276
+ type AgentEventType = 'call.incoming' | 'call.ended' | 'call.outbound_ready' | 'call.ringing' | 'call.failed';
277
+ type AgentEventHandler = (session: CallSession) => void | Promise<void>;
278
+ interface ClawOpsAgentOptions {
279
+ /** ClawOps API key. Falls back to CLAWOPS_API_KEY env var. */
280
+ apiKey?: string;
281
+ /** Agent ID. Falls back to CLAWOPS_AGENT_ID env var. */
282
+ agentId?: string;
283
+ /** API base URL. */
284
+ baseUrl?: string;
285
+ /** Session factory: returns the session handler for each call. */
286
+ session?: Session | (() => Session);
287
+ /** Recording output directory. If set, calls are recorded. */
288
+ recordingDir?: string;
289
+ /** MCP server configurations. */
290
+ mcpServers?: Record<string, MCPServerStdio | MCPServerHTTP>;
291
+ /** Tracing configuration. */
292
+ tracing?: TracingConfig;
293
+ }
294
+ declare class ClawOpsAgent {
295
+ private _apiKey;
296
+ private _agentId;
297
+ private _baseUrl;
298
+ private _sessionFactory;
299
+ private _tools;
300
+ private _handlers;
301
+ private _controlWs;
302
+ private _mcpClient;
303
+ private _recordingDir;
304
+ private _activeSessions;
305
+ constructor(options?: ClawOpsAgentOptions);
306
+ /** Register a function tool. */
307
+ tool(tool: FunctionTool): this;
308
+ /** Register an event handler. */
309
+ on(event: AgentEventType, handler: AgentEventHandler): this;
310
+ /** Connect to the ClawOps platform and start listening for calls. */
311
+ connect(): Promise<void>;
312
+ /**
313
+ * Connect and block until disconnected.
314
+ * Convenience method for simple agent scripts.
315
+ */
316
+ serve(): Promise<void>;
317
+ /** Disconnect from the platform. */
318
+ disconnect(): Promise<void>;
319
+ /**
320
+ * Initiate an outbound call.
321
+ */
322
+ call(options: {
323
+ to: string;
324
+ from: string;
325
+ metadata?: Record<string, unknown>;
326
+ }): void;
327
+ private _handleIncoming;
328
+ private _handleEnded;
329
+ private _handleOutboundReady;
330
+ private _handleRinging;
331
+ private _handleFailed;
332
+ private _startCallSession;
333
+ private _emitEvent;
334
+ }
335
+
336
+ /**
337
+ * Audio codec utilities: PCM16 <-> ulaw conversion and resampling.
338
+ */
339
+ declare const DECODE_TABLE: readonly number[];
340
+ /**
341
+ * Convert PCM16 little-endian audio to ulaw.
342
+ */
343
+ declare function pcm16ToUlaw(pcm: Buffer): Buffer;
344
+ /**
345
+ * Convert ulaw audio to PCM16 little-endian.
346
+ */
347
+ declare function ulawToPcm16(ulaw: Buffer): Buffer;
348
+ /**
349
+ * Resample PCM16 audio using linear interpolation.
350
+ */
351
+ declare function resamplePcm16(pcm: Buffer, fromRate: number, toRate: number): Buffer;
352
+
353
+ /**
354
+ * AudioRecorder writes inbound and outbound audio to a WAV file.
355
+ */
356
+ interface RecorderOptions {
357
+ /** Output directory for recordings. */
358
+ outputDir: string;
359
+ /** Sample rate of audio data. Default: 8000 */
360
+ sampleRate?: number;
361
+ }
362
+ declare class AudioRecorder {
363
+ private readonly _outputDir;
364
+ private readonly _sampleRate;
365
+ private _inboundChunks;
366
+ private _outboundChunks;
367
+ private _callId;
368
+ private _started;
369
+ constructor(options: RecorderOptions);
370
+ /** Start recording for a call. */
371
+ start(callId: string): void;
372
+ /** Write inbound (caller) PCM16 audio. */
373
+ writeInbound(pcm: Buffer): void;
374
+ /** Write raw outbound (agent) PCM16 audio. */
375
+ writeRawOutbound(pcm: Buffer): void;
376
+ /** Stop recording and write WAV files to disk. Returns file paths. */
377
+ stop(): {
378
+ inbound?: string;
379
+ outbound?: string;
380
+ };
381
+ private _writeWav;
382
+ }
383
+
384
+ /**
385
+ * OpenAI Realtime API session (speech-to-speech).
386
+ */
387
+
388
+ interface OpenAIRealtimeOptions {
389
+ /** OpenAI API key. Falls back to OPENAI_API_KEY env var. */
390
+ apiKey?: string;
391
+ /** Model to use. Default: 'gpt-4o-realtime-preview' */
392
+ model?: string;
393
+ /** Voice ID. Default: 'alloy' */
394
+ voice?: string;
395
+ /** System prompt / instructions. */
396
+ instructions?: string;
397
+ /** Input audio format. Default: 'pcm16' */
398
+ inputAudioFormat?: string;
399
+ /** Output audio format. Default: 'pcm16' */
400
+ outputAudioFormat?: string;
401
+ /** Temperature for generation. */
402
+ temperature?: number;
403
+ /** Turn detection config. Set to null to disable. */
404
+ turnDetection?: Record<string, unknown> | null;
405
+ }
406
+ declare class OpenAIRealtime implements Session {
407
+ private _options;
408
+ private _ws;
409
+ private _callSession;
410
+ private _tools;
411
+ private _closed;
412
+ constructor(options?: OpenAIRealtimeOptions);
413
+ start(callSession: CallSession, tools?: ToolRegistry): Promise<void>;
414
+ feedAudio(audio: Buffer): void;
415
+ stop(): Promise<void>;
416
+ private _sendSessionUpdate;
417
+ private _handleMessage;
418
+ private _handleFunctionCall;
419
+ }
420
+
421
+ /**
422
+ * Google Gemini Realtime API session (speech-to-speech).
423
+ */
424
+
425
+ interface GeminiRealtimeOptions {
426
+ /** Google API key. Falls back to GOOGLE_API_KEY env var. */
427
+ apiKey?: string;
428
+ /** Model to use. Default: 'gemini-2.0-flash-exp' */
429
+ model?: string;
430
+ /** Voice name. */
431
+ voice?: string;
432
+ /** System instruction. */
433
+ systemInstruction?: string;
434
+ /** Generation config overrides. */
435
+ generationConfig?: Record<string, unknown>;
436
+ }
437
+ declare class GeminiRealtime implements Session {
438
+ private _options;
439
+ private _ws;
440
+ private _callSession;
441
+ private _tools;
442
+ private _closed;
443
+ constructor(options?: GeminiRealtimeOptions);
444
+ start(callSession: CallSession, tools?: ToolRegistry): Promise<void>;
445
+ feedAudio(audio: Buffer): void;
446
+ stop(): Promise<void>;
447
+ private _sendSetup;
448
+ private _handleMessage;
449
+ private _handleToolCall;
450
+ }
451
+
452
+ /**
453
+ * PipelineSession orchestrates STT -> LLM -> TTS for a voice call.
454
+ */
455
+
456
+ interface PipelineSessionOptions {
457
+ stt: STT;
458
+ llm: LLM;
459
+ tts: TTS;
460
+ /** System prompt for the LLM. */
461
+ systemPrompt?: string;
462
+ /** LLM temperature. */
463
+ temperature?: number;
464
+ /** Max tokens for LLM generation. */
465
+ maxTokens?: number;
466
+ /** Sample rate for audio. Default: 8000 */
467
+ sampleRate?: number;
468
+ /** Whether to interrupt TTS when user starts speaking. Default: true */
469
+ interruptOnSpeech?: boolean;
470
+ }
471
+ declare class PipelineSession implements Session {
472
+ private _stt;
473
+ private _llm;
474
+ private _tts;
475
+ private _systemPrompt;
476
+ private _temperature;
477
+ private _maxTokens;
478
+ private _sampleRate;
479
+ private _interruptOnSpeech;
480
+ private _callSession;
481
+ private _tools;
482
+ private _conversation;
483
+ private _audioBuffer;
484
+ private _running;
485
+ private _speaking;
486
+ constructor(options: PipelineSessionOptions);
487
+ start(callSession: CallSession, tools?: ToolRegistry): Promise<void>;
488
+ feedAudio(audio: Buffer): void;
489
+ stop(): Promise<void>;
490
+ private _runSttLoop;
491
+ private _createAudioStream;
492
+ private _handleUserSpeech;
493
+ private _handleToolCall;
494
+ private _synthesizeAndSend;
495
+ }
496
+
497
+ /**
498
+ * Deepgram STT (Speech-to-Text) provider.
499
+ */
500
+
501
+ interface DeepgramSTTOptions {
502
+ /** Deepgram API key. Falls back to DEEPGRAM_API_KEY env var. */
503
+ apiKey?: string;
504
+ /** Model to use. Default: 'nova-2' */
505
+ model?: string;
506
+ /** Language code. Default: 'ko' */
507
+ language?: string;
508
+ /** Enable interim results. Default: true */
509
+ interimResults?: boolean;
510
+ /** Enable punctuation. Default: true */
511
+ punctuate?: boolean;
512
+ /** Enable smart formatting. Default: true */
513
+ smartFormat?: boolean;
514
+ /** Encoding. Default: 'linear16' */
515
+ encoding?: string;
516
+ /** Sample rate. Default: 8000 */
517
+ sampleRate?: number;
518
+ /** Number of channels. Default: 1 */
519
+ channels?: number;
520
+ }
521
+ declare class DeepgramSTT implements STT {
522
+ private _options;
523
+ constructor(options?: DeepgramSTTOptions);
524
+ transcribe(audioStream: AsyncIterable<Buffer>, options?: {
525
+ language?: string;
526
+ sampleRate?: number;
527
+ }): AsyncGenerator<SpeechEvent>;
528
+ }
529
+
530
+ /**
531
+ * ElevenLabs TTS (Text-to-Speech) provider.
532
+ */
533
+
534
+ interface ElevenLabsTTSOptions {
535
+ /** ElevenLabs API key. Falls back to ELEVENLABS_API_KEY env var. */
536
+ apiKey?: string;
537
+ /** Voice ID. Default: '21m00Tcm4TlvDq8ikWAM' (Rachel) */
538
+ voiceId?: string;
539
+ /** Model ID. Default: 'eleven_multilingual_v2' */
540
+ modelId?: string;
541
+ /** Output format. Default: 'pcm_16000' */
542
+ outputFormat?: string;
543
+ /** Stability. Default: 0.5 */
544
+ stability?: number;
545
+ /** Similarity boost. Default: 0.75 */
546
+ similarityBoost?: number;
547
+ /** Style. Default: 0 */
548
+ style?: number;
549
+ /** Use speaker boost. Default: true */
550
+ useSpeakerBoost?: boolean;
551
+ }
552
+ declare class ElevenLabsTTS implements TTS {
553
+ private _options;
554
+ constructor(options?: ElevenLabsTTSOptions);
555
+ synthesize(text: string | AsyncIterable<string>, options?: {
556
+ voice?: string;
557
+ sampleRate?: number;
558
+ }): AsyncGenerator<Buffer>;
559
+ private _synthesizeSingle;
560
+ private _synthesizeStreaming;
561
+ }
562
+
563
+ /**
564
+ * OpenAI LLM provider for pipeline-based voice agents.
565
+ */
566
+
567
+ interface OpenAILLMOptions {
568
+ /** OpenAI API key. Falls back to OPENAI_API_KEY env var. */
569
+ apiKey?: string;
570
+ /** Model to use. Default: 'gpt-4o' */
571
+ model?: string;
572
+ /** Default temperature. */
573
+ temperature?: number;
574
+ /** Default max tokens. */
575
+ maxTokens?: number;
576
+ }
577
+ declare class OpenAILLM implements LLM {
578
+ private _options;
579
+ constructor(options?: OpenAILLMOptions);
580
+ generate(messages: ConversationMessage[], options?: {
581
+ tools?: ToolRegistry;
582
+ temperature?: number;
583
+ maxTokens?: number;
584
+ }): AsyncGenerator<LLMChunk>;
585
+ }
586
+
587
+ /**
588
+ * Anthropic LLM provider for pipeline-based voice agents.
589
+ */
590
+
591
+ interface AnthropicLLMOptions {
592
+ /** Anthropic API key. Falls back to ANTHROPIC_API_KEY env var. */
593
+ apiKey?: string;
594
+ /** Model to use. Default: 'claude-sonnet-4-20250514' */
595
+ model?: string;
596
+ /** Default temperature. */
597
+ temperature?: number;
598
+ /** Default max tokens. Default: 1024 */
599
+ maxTokens?: number;
600
+ }
601
+ declare class AnthropicLLM implements LLM {
602
+ private _options;
603
+ constructor(options?: AnthropicLLMOptions);
604
+ generate(messages: ConversationMessage[], options?: {
605
+ tools?: ToolRegistry;
606
+ temperature?: number;
607
+ maxTokens?: number;
608
+ }): AsyncGenerator<LLMChunk>;
609
+ }
610
+
611
+ /**
612
+ * Google Gemini LLM provider for pipeline-based voice agents.
613
+ */
614
+
615
+ interface GeminiLLMOptions {
616
+ /** Google API key. Falls back to GOOGLE_API_KEY env var. */
617
+ apiKey?: string;
618
+ /** Model to use. Default: 'gemini-2.0-flash' */
619
+ model?: string;
620
+ /** Default temperature. */
621
+ temperature?: number;
622
+ /** Default max tokens. */
623
+ maxTokens?: number;
624
+ }
625
+ declare class GeminiLLM implements LLM {
626
+ private _options;
627
+ constructor(options?: GeminiLLMOptions);
628
+ generate(messages: ConversationMessage[], options?: {
629
+ tools?: ToolRegistry;
630
+ temperature?: number;
631
+ maxTokens?: number;
632
+ }): AsyncGenerator<LLMChunk>;
633
+ }
634
+
635
+ /**
636
+ * OpenAI-compatible LLM provider (works with any OpenAI-compatible API).
637
+ */
638
+
639
+ interface OpenAICompatLLMOptions {
640
+ /** API key. */
641
+ apiKey?: string;
642
+ /** Base URL for the OpenAI-compatible API. */
643
+ baseUrl: string;
644
+ /** Model to use. */
645
+ model: string;
646
+ /** Default temperature. */
647
+ temperature?: number;
648
+ /** Default max tokens. */
649
+ maxTokens?: number;
650
+ /** Additional default headers. */
651
+ defaultHeaders?: Record<string, string>;
652
+ }
653
+ declare class OpenAICompatLLM implements LLM {
654
+ private _options;
655
+ constructor(options: OpenAICompatLLMOptions);
656
+ generate(messages: ConversationMessage[], options?: {
657
+ tools?: ToolRegistry;
658
+ temperature?: number;
659
+ maxTokens?: number;
660
+ }): AsyncGenerator<LLMChunk>;
661
+ }
662
+
663
+ /**
664
+ * Ollama LLM provider for pipeline-based voice agents.
665
+ * Uses the OpenAI-compatible API that Ollama exposes.
666
+ */
667
+
668
+ interface OllamaLLMOptions {
669
+ /** Ollama server URL. Default: 'http://localhost:11434' */
670
+ baseUrl?: string;
671
+ /** Model to use. Default: 'llama3.1' */
672
+ model?: string;
673
+ /** Default temperature. */
674
+ temperature?: number;
675
+ /** Default max tokens. */
676
+ maxTokens?: number;
677
+ }
678
+ declare class OllamaLLM implements LLM {
679
+ private _inner;
680
+ constructor(options?: OllamaLLMOptions);
681
+ generate(messages: ConversationMessage[], options?: {
682
+ tools?: ToolRegistry;
683
+ temperature?: number;
684
+ maxTokens?: number;
685
+ }): AsyncGenerator<LLMChunk>;
686
+ }
687
+
688
+ interface MistralLLMOptions {
689
+ apiKey?: string;
690
+ model?: string;
691
+ temperature?: number;
692
+ maxTokens?: number;
693
+ }
694
+ declare class MistralLLM implements LLM {
695
+ private _inner;
696
+ constructor(options?: MistralLLMOptions);
697
+ generate(messages: ConversationMessage[], options?: {
698
+ tools?: ToolRegistry;
699
+ temperature?: number;
700
+ maxTokens?: number;
701
+ }): AsyncGenerator<LLMChunk>;
702
+ }
703
+
704
+ interface GroqLLMOptions {
705
+ apiKey?: string;
706
+ model?: string;
707
+ temperature?: number;
708
+ maxTokens?: number;
709
+ }
710
+ declare class GroqLLM implements LLM {
711
+ private _inner;
712
+ constructor(options?: GroqLLMOptions);
713
+ generate(messages: ConversationMessage[], options?: {
714
+ tools?: ToolRegistry;
715
+ temperature?: number;
716
+ maxTokens?: number;
717
+ }): AsyncGenerator<LLMChunk>;
718
+ }
719
+
720
+ interface PerplexityLLMOptions {
721
+ apiKey?: string;
722
+ model?: string;
723
+ temperature?: number;
724
+ maxTokens?: number;
725
+ }
726
+ declare class PerplexityLLM implements LLM {
727
+ private _inner;
728
+ constructor(options?: PerplexityLLMOptions);
729
+ generate(messages: ConversationMessage[], options?: {
730
+ tools?: ToolRegistry;
731
+ temperature?: number;
732
+ maxTokens?: number;
733
+ }): AsyncGenerator<LLMChunk>;
734
+ }
735
+
736
+ interface TogetherLLMOptions {
737
+ apiKey?: string;
738
+ model?: string;
739
+ temperature?: number;
740
+ maxTokens?: number;
741
+ }
742
+ declare class TogetherLLM implements LLM {
743
+ private _inner;
744
+ constructor(options?: TogetherLLMOptions);
745
+ generate(messages: ConversationMessage[], options?: {
746
+ tools?: ToolRegistry;
747
+ temperature?: number;
748
+ maxTokens?: number;
749
+ }): AsyncGenerator<LLMChunk>;
750
+ }
751
+
752
+ interface FireworksLLMOptions {
753
+ apiKey?: string;
754
+ model?: string;
755
+ temperature?: number;
756
+ maxTokens?: number;
757
+ }
758
+ declare class FireworksLLM implements LLM {
759
+ private _inner;
760
+ constructor(options?: FireworksLLMOptions);
761
+ generate(messages: ConversationMessage[], options?: {
762
+ tools?: ToolRegistry;
763
+ temperature?: number;
764
+ maxTokens?: number;
765
+ }): AsyncGenerator<LLMChunk>;
766
+ }
767
+
768
+ interface DeepSeekLLMOptions {
769
+ apiKey?: string;
770
+ model?: string;
771
+ temperature?: number;
772
+ maxTokens?: number;
773
+ }
774
+ declare class DeepSeekLLM implements LLM {
775
+ private _inner;
776
+ constructor(options?: DeepSeekLLMOptions);
777
+ generate(messages: ConversationMessage[], options?: {
778
+ tools?: ToolRegistry;
779
+ temperature?: number;
780
+ maxTokens?: number;
781
+ }): AsyncGenerator<LLMChunk>;
782
+ }
783
+
784
+ interface XaiLLMOptions {
785
+ apiKey?: string;
786
+ model?: string;
787
+ temperature?: number;
788
+ maxTokens?: number;
789
+ }
790
+ declare class XaiLLM implements LLM {
791
+ private _inner;
792
+ constructor(options?: XaiLLMOptions);
793
+ generate(messages: ConversationMessage[], options?: {
794
+ tools?: ToolRegistry;
795
+ temperature?: number;
796
+ maxTokens?: number;
797
+ }): AsyncGenerator<LLMChunk>;
798
+ }
799
+
800
+ /**
801
+ * MCP (Model Context Protocol) client for discovering and calling tools.
802
+ */
803
+
804
+ interface MCPServerConfig {
805
+ /** Server type discriminator. */
806
+ type: 'stdio' | 'http';
807
+ [key: string]: unknown;
808
+ }
809
+ declare class MCPClient {
810
+ private _servers;
811
+ private _clients;
812
+ /** Add an MCP server configuration. */
813
+ addServer(name: string, config: MCPServerConfig & Record<string, unknown>): void;
814
+ /** Connect to all configured MCP servers and discover tools. */
815
+ connect(): Promise<FunctionTool[]>;
816
+ /** Disconnect from all MCP servers. */
817
+ disconnect(): Promise<void>;
818
+ private _connectServer;
819
+ }
820
+
821
+ export { type AgentEventType, AnthropicLLM, type AnthropicLLMOptions, AudioRecorder, type CallDirection, CallSession, type CallStatus, ClawOpsAgent, type ClawOpsAgentOptions, type ConversationMessage, DECODE_TABLE, DeepSeekLLM, type DeepSeekLLMOptions, DeepgramSTT, type DeepgramSTTOptions, ElevenLabsTTS, type ElevenLabsTTSOptions, FireworksLLM, type FireworksLLMOptions, type FunctionTool, GeminiLLM, type GeminiLLMOptions, GeminiRealtime, type GeminiRealtimeOptions, GroqLLM, type GroqLLMOptions, type LLM, type LLMChunk, MCPClient, type MCPServerConfig, type MCPServerHTTP, type MCPServerStdio, MistralLLM, type MistralLLMOptions, OllamaLLM, type OllamaLLMOptions, OpenAICompatLLM, type OpenAICompatLLMOptions, OpenAILLM, type OpenAILLMOptions, OpenAIRealtime, type OpenAIRealtimeOptions, type OpenAIToolDefinition, PerplexityLLM, type PerplexityLLMOptions, PipelineSession, type PipelineSessionOptions, type RecorderOptions, type STT, type Session, type SessionEventType, type SpeechEvent, type TTS, TogetherLLM, type TogetherLLMOptions, ToolRegistry, type TracingConfig, XaiLLM, type XaiLLMOptions, functionTool, getTracingConfig, mcpServerHTTP, mcpServerStdio, pcm16ToUlaw, resamplePcm16, resetTracingConfig, setTracingConfig, ulawToPcm16, zodToToolParams };