@teamlearners/clawops 0.1.0 → 0.3.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/README.md +6 -0
- package/dist/agent/index.cjs +794 -414
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +255 -196
- package/dist/agent/index.d.ts +255 -196
- package/dist/agent/index.js +794 -414
- package/dist/agent/index.js.map +1 -1
- package/dist/index.cjs +4 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,5 +1,88 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Tool registry for function-calling in voice agent pipelines.
|
|
5
|
+
* Uses Zod schemas for parameter validation.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
interface FunctionTool {
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
parameters: Record<string, unknown>;
|
|
12
|
+
required: string[];
|
|
13
|
+
handler: (args: Record<string, unknown>) => unknown | Promise<unknown>;
|
|
14
|
+
}
|
|
15
|
+
interface OpenAIToolDefinition {
|
|
16
|
+
type: 'function';
|
|
17
|
+
function: {
|
|
18
|
+
name: string;
|
|
19
|
+
description: string;
|
|
20
|
+
parameters: {
|
|
21
|
+
type: 'object';
|
|
22
|
+
properties: Record<string, unknown>;
|
|
23
|
+
required: string[];
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Decorator / identity function for marking a function as a tool handler.
|
|
29
|
+
* In TypeScript, this simply returns the function as-is. Use with ToolRegistry.register().
|
|
30
|
+
*/
|
|
31
|
+
declare function functionTool<T extends (...args: unknown[]) => unknown>(fn: T): T;
|
|
32
|
+
declare class ToolRegistry {
|
|
33
|
+
private _tools;
|
|
34
|
+
private _mcpTools;
|
|
35
|
+
/** Register a function tool. */
|
|
36
|
+
register(tool: FunctionTool): void;
|
|
37
|
+
/** Register tools discovered from MCP servers. */
|
|
38
|
+
registerMcpTools(tools: FunctionTool[]): void;
|
|
39
|
+
/** Clear all MCP-registered tools. */
|
|
40
|
+
clearMcpTools(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Create a fork (shallow copy) of this registry.
|
|
43
|
+
* Useful for per-session tool isolation.
|
|
44
|
+
*/
|
|
45
|
+
fork(): ToolRegistry;
|
|
46
|
+
/** Check if a tool is registered. */
|
|
47
|
+
has(name: string): boolean;
|
|
48
|
+
/** Get a tool by name. */
|
|
49
|
+
get(name: string): FunctionTool | undefined;
|
|
50
|
+
/** Convert all registered tools to OpenAI function-calling format. */
|
|
51
|
+
toOpenAITools(): OpenAIToolDefinition[];
|
|
52
|
+
/** Call a tool by name with the given arguments. */
|
|
53
|
+
call(name: string, args: Record<string, unknown>): Promise<unknown>;
|
|
54
|
+
/** Get the number of registered tools (including MCP). */
|
|
55
|
+
get size(): number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Helper to convert a Zod object schema into a JSON Schema properties + required list.
|
|
59
|
+
*/
|
|
60
|
+
declare function zodToToolParams(schema: z.ZodObject<z.ZodRawShape>): {
|
|
61
|
+
parameters: Record<string, unknown>;
|
|
62
|
+
required: string[];
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* MCP (Model Context Protocol) client for discovering and calling tools.
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
interface MCPServerConfig {
|
|
70
|
+
/** Server type discriminator. */
|
|
71
|
+
type: 'stdio' | 'http';
|
|
72
|
+
[key: string]: unknown;
|
|
73
|
+
}
|
|
74
|
+
declare class MCPClient {
|
|
75
|
+
private _servers;
|
|
76
|
+
private _clients;
|
|
77
|
+
/** Add an MCP server configuration. */
|
|
78
|
+
addServer(name: string, config: MCPServerConfig & Record<string, unknown>): void;
|
|
79
|
+
/** Connect to all configured MCP servers and discover tools. */
|
|
80
|
+
connect(): Promise<FunctionTool[]>;
|
|
81
|
+
/** Disconnect from all MCP servers. */
|
|
82
|
+
disconnect(): Promise<void>;
|
|
83
|
+
private _connectServer;
|
|
84
|
+
}
|
|
85
|
+
|
|
3
86
|
/**
|
|
4
87
|
* MCP server configuration for stdio-based servers.
|
|
5
88
|
*/
|
|
@@ -47,12 +130,11 @@ declare function mcpServerHTTP(options: {
|
|
|
47
130
|
*/
|
|
48
131
|
type CallDirection = 'inbound' | 'outbound';
|
|
49
132
|
type CallStatus = 'ringing' | 'active' | 'ended';
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
type SessionEventHandler = (event: SessionEvent) => void | Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* Session event handler: receives (call, ...args) like the Python SDK.
|
|
135
|
+
* For example, 'transcript' events pass (call, role, text).
|
|
136
|
+
*/
|
|
137
|
+
type SessionEventHandler = (...args: any[]) => void | Promise<void>;
|
|
56
138
|
interface SendAudioFn {
|
|
57
139
|
(audio: Buffer): void;
|
|
58
140
|
}
|
|
@@ -96,77 +178,15 @@ declare class CallSession {
|
|
|
96
178
|
/** Hang up the call. */
|
|
97
179
|
hangup(): void;
|
|
98
180
|
/** Register an event handler. */
|
|
99
|
-
on(event:
|
|
181
|
+
on(event: string, handler: SessionEventHandler): void;
|
|
100
182
|
/** Wait for the call to end. */
|
|
101
183
|
wait(): Promise<void>;
|
|
102
184
|
/** Mark the session as ended (called internally). */
|
|
103
185
|
_markEnded(): void;
|
|
104
|
-
/** Emit an event to registered handlers. */
|
|
105
|
-
_emit(event:
|
|
186
|
+
/** Emit an event to registered handlers. Matches Python SDK: _emit(event, ...args) */
|
|
187
|
+
_emit(event: string, ...args: any[]): void;
|
|
106
188
|
}
|
|
107
189
|
|
|
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
190
|
/**
|
|
171
191
|
* Base interfaces for the voice agent pipeline.
|
|
172
192
|
*/
|
|
@@ -273,39 +293,57 @@ declare function resetTracingConfig(): void;
|
|
|
273
293
|
* ClawOpsAgent - main agent class for handling voice calls.
|
|
274
294
|
*/
|
|
275
295
|
|
|
276
|
-
type AgentEventType = '
|
|
277
|
-
type AgentEventHandler = (
|
|
296
|
+
type AgentEventType = 'call_start' | 'call_end' | 'call_failed' | 'transcript';
|
|
297
|
+
type AgentEventHandler = (...args: any[]) => void | Promise<void>;
|
|
278
298
|
interface ClawOpsAgentOptions {
|
|
279
299
|
/** ClawOps API key. Falls back to CLAWOPS_API_KEY env var. */
|
|
280
300
|
apiKey?: string;
|
|
281
|
-
/**
|
|
282
|
-
|
|
301
|
+
/** Account ID. Falls back to CLAWOPS_ACCOUNT_ID env var. */
|
|
302
|
+
accountId?: string;
|
|
283
303
|
/** API base URL. */
|
|
284
304
|
baseUrl?: string;
|
|
285
|
-
/**
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
|
|
305
|
+
/** Phone number to send/receive calls from. Required. */
|
|
306
|
+
from: string;
|
|
307
|
+
/** Session implementation (OpenAIRealtime, GeminiRealtime, PipelineSession, etc.). */
|
|
308
|
+
session: Session;
|
|
309
|
+
/** Enable call recording. */
|
|
310
|
+
recording?: boolean;
|
|
311
|
+
/** Recording output directory. Default: './recordings' */
|
|
312
|
+
recordingPath?: string;
|
|
289
313
|
/** MCP server configurations. */
|
|
290
|
-
mcpServers?:
|
|
314
|
+
mcpServers?: Array<MCPServerStdio | MCPServerHTTP>;
|
|
291
315
|
/** Tracing configuration. */
|
|
292
316
|
tracing?: TracingConfig;
|
|
293
317
|
}
|
|
294
318
|
declare class ClawOpsAgent {
|
|
295
319
|
private _apiKey;
|
|
296
|
-
private
|
|
320
|
+
private _accountId;
|
|
297
321
|
private _baseUrl;
|
|
298
|
-
private
|
|
322
|
+
private _fromNumber;
|
|
323
|
+
private _session;
|
|
299
324
|
private _tools;
|
|
300
325
|
private _handlers;
|
|
301
326
|
private _controlWs;
|
|
302
|
-
private
|
|
303
|
-
private
|
|
327
|
+
private _mcpServers;
|
|
328
|
+
private _recording;
|
|
329
|
+
private _recordingPath;
|
|
304
330
|
private _activeSessions;
|
|
305
|
-
constructor(options
|
|
306
|
-
/**
|
|
307
|
-
|
|
308
|
-
|
|
331
|
+
constructor(options: ClawOpsAgentOptions);
|
|
332
|
+
/**
|
|
333
|
+
* Register a function tool.
|
|
334
|
+
*
|
|
335
|
+
* Supports two signatures (matching Python SDK):
|
|
336
|
+
* agent.tool(name, description, parameters, handler)
|
|
337
|
+
* agent.tool(functionToolObject)
|
|
338
|
+
*/
|
|
339
|
+
tool(nameOrTool: string | FunctionTool, description?: string, parameters?: Record<string, unknown>, handler?: (args: Record<string, unknown>) => unknown | Promise<unknown>): this;
|
|
340
|
+
/**
|
|
341
|
+
* Register an event handler.
|
|
342
|
+
*
|
|
343
|
+
* Matches Python SDK decorator style:
|
|
344
|
+
* agent.on("call_start", (call) => { ... })
|
|
345
|
+
* agent.on("transcript", (call, role, text) => { ... })
|
|
346
|
+
*/
|
|
309
347
|
on(event: AgentEventType, handler: AgentEventHandler): this;
|
|
310
348
|
/** Connect to the ClawOps platform and start listening for calls. */
|
|
311
349
|
connect(): Promise<void>;
|
|
@@ -318,19 +356,17 @@ declare class ClawOpsAgent {
|
|
|
318
356
|
disconnect(): Promise<void>;
|
|
319
357
|
/**
|
|
320
358
|
* Initiate an outbound call.
|
|
359
|
+
* Matches Python SDK: agent.call(to, { timeout })
|
|
321
360
|
*/
|
|
322
|
-
call(
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
metadata?: Record<string, unknown>;
|
|
326
|
-
}): void;
|
|
361
|
+
call(to: string, options?: {
|
|
362
|
+
timeout?: number;
|
|
363
|
+
}): Promise<CallSession>;
|
|
327
364
|
private _handleIncoming;
|
|
328
365
|
private _handleEnded;
|
|
329
366
|
private _handleOutboundReady;
|
|
330
367
|
private _handleRinging;
|
|
331
368
|
private _handleFailed;
|
|
332
369
|
private _startCallSession;
|
|
333
|
-
private _emitEvent;
|
|
334
370
|
}
|
|
335
371
|
|
|
336
372
|
/**
|
|
@@ -350,102 +386,133 @@ declare function ulawToPcm16(ulaw: Buffer): Buffer;
|
|
|
350
386
|
*/
|
|
351
387
|
declare function resamplePcm16(pcm: Buffer, fromRate: number, toRate: number): Buffer;
|
|
352
388
|
|
|
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
389
|
declare class AudioRecorder {
|
|
363
|
-
private readonly
|
|
364
|
-
private
|
|
365
|
-
private
|
|
366
|
-
private
|
|
367
|
-
private
|
|
390
|
+
private readonly _dir;
|
|
391
|
+
private _fdIn;
|
|
392
|
+
private _fdOut;
|
|
393
|
+
private _fdMix;
|
|
394
|
+
private _inWritten;
|
|
395
|
+
private _outWritten;
|
|
396
|
+
private _mixWritten;
|
|
397
|
+
private _startTime;
|
|
368
398
|
private _started;
|
|
369
|
-
constructor(
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
stop(): {
|
|
378
|
-
inbound?: string;
|
|
379
|
-
outbound?: string;
|
|
380
|
-
};
|
|
381
|
-
private _writeWav;
|
|
399
|
+
constructor(recordingPath: string, callId: string);
|
|
400
|
+
start(): void;
|
|
401
|
+
private _expectedBytes;
|
|
402
|
+
private _padSilence;
|
|
403
|
+
private _writeToMix;
|
|
404
|
+
writeInbound(pcm16_8k: Buffer): void;
|
|
405
|
+
writeOutbound(pcm16_8k: Buffer): void;
|
|
406
|
+
stop(): void;
|
|
382
407
|
}
|
|
383
408
|
|
|
384
409
|
/**
|
|
385
410
|
* OpenAI Realtime API session (speech-to-speech).
|
|
411
|
+
*
|
|
412
|
+
* Matches Python SDK's OpenAIRealtime implementation.
|
|
386
413
|
*/
|
|
387
414
|
|
|
388
415
|
interface OpenAIRealtimeOptions {
|
|
389
416
|
/** OpenAI API key. Falls back to OPENAI_API_KEY env var. */
|
|
390
417
|
apiKey?: string;
|
|
391
|
-
/**
|
|
418
|
+
/** System prompt / instructions for the AI. */
|
|
419
|
+
systemPrompt?: string;
|
|
420
|
+
/** Model to use. Default: 'gpt-realtime-1.5' */
|
|
392
421
|
model?: string;
|
|
393
|
-
/** Voice ID. Default: '
|
|
422
|
+
/** Voice ID. Default: 'marin' */
|
|
394
423
|
voice?: string;
|
|
395
|
-
/**
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
|
|
399
|
-
/**
|
|
400
|
-
|
|
401
|
-
/** Temperature for generation. */
|
|
402
|
-
temperature?: number;
|
|
403
|
-
/** Turn detection config. Set to null to disable. */
|
|
404
|
-
turnDetection?: Record<string, unknown> | null;
|
|
424
|
+
/** Language code (BCP 47). Default: 'ko' */
|
|
425
|
+
language?: string;
|
|
426
|
+
/** VAD eagerness: 'low', 'medium', 'high'. Default: 'high' */
|
|
427
|
+
eagerness?: string;
|
|
428
|
+
/** Send initial greeting. Default: true */
|
|
429
|
+
greeting?: boolean;
|
|
405
430
|
}
|
|
406
431
|
declare class OpenAIRealtime implements Session {
|
|
407
|
-
private
|
|
432
|
+
private _apiKey;
|
|
433
|
+
private _systemPrompt;
|
|
434
|
+
private _model;
|
|
435
|
+
private _voice;
|
|
436
|
+
private _language;
|
|
437
|
+
private _eagerness;
|
|
438
|
+
private _greeting;
|
|
408
439
|
private _ws;
|
|
409
|
-
private
|
|
440
|
+
private _call;
|
|
410
441
|
private _tools;
|
|
442
|
+
private _recorder;
|
|
411
443
|
private _closed;
|
|
444
|
+
private _lastAssistantItem;
|
|
445
|
+
private _responseStartTs;
|
|
446
|
+
private _sentAudioChunks;
|
|
447
|
+
private _audioRemainder;
|
|
412
448
|
constructor(options?: OpenAIRealtimeOptions);
|
|
449
|
+
/** Inject per-call ToolRegistry. */
|
|
450
|
+
setToolRegistry(registry: ToolRegistry): void;
|
|
451
|
+
/** Inject per-call AudioRecorder. */
|
|
452
|
+
setRecorder(recorder: AudioRecorder): void;
|
|
413
453
|
start(callSession: CallSession, tools?: ToolRegistry): Promise<void>;
|
|
414
454
|
feedAudio(audio: Buffer): void;
|
|
415
455
|
stop(): Promise<void>;
|
|
416
456
|
private _sendSessionUpdate;
|
|
417
457
|
private _handleMessage;
|
|
418
|
-
private
|
|
458
|
+
private _handleAudioDelta;
|
|
459
|
+
private _handleTruncation;
|
|
460
|
+
private _handleToolCall;
|
|
461
|
+
private _send;
|
|
419
462
|
}
|
|
420
463
|
|
|
421
464
|
/**
|
|
422
465
|
* Google Gemini Realtime API session (speech-to-speech).
|
|
466
|
+
*
|
|
467
|
+
* Matches Python SDK's GeminiRealtime implementation.
|
|
423
468
|
*/
|
|
424
469
|
|
|
425
470
|
interface GeminiRealtimeOptions {
|
|
426
471
|
/** Google API key. Falls back to GOOGLE_API_KEY env var. */
|
|
427
472
|
apiKey?: string;
|
|
428
|
-
/**
|
|
473
|
+
/** System prompt / instructions for the AI. */
|
|
474
|
+
systemPrompt?: string;
|
|
475
|
+
/** Model to use. Default: 'gemini-2.5-flash-native-audio-preview-12-2025' */
|
|
429
476
|
model?: string;
|
|
430
|
-
/** Voice name. */
|
|
477
|
+
/** Voice name. Default: 'Kore' */
|
|
431
478
|
voice?: string;
|
|
432
|
-
/**
|
|
433
|
-
|
|
479
|
+
/** Language code. Default: 'ko' */
|
|
480
|
+
language?: string;
|
|
481
|
+
/** Send initial greeting. Default: true */
|
|
482
|
+
greeting?: boolean;
|
|
434
483
|
/** Generation config overrides. */
|
|
435
484
|
generationConfig?: Record<string, unknown>;
|
|
436
485
|
}
|
|
437
486
|
declare class GeminiRealtime implements Session {
|
|
438
|
-
private
|
|
487
|
+
private _apiKey;
|
|
488
|
+
private _systemPrompt;
|
|
489
|
+
private _model;
|
|
490
|
+
private _voice;
|
|
491
|
+
private _language;
|
|
492
|
+
private _greeting;
|
|
493
|
+
private _generationConfig;
|
|
439
494
|
private _ws;
|
|
440
|
-
private
|
|
495
|
+
private _call;
|
|
441
496
|
private _tools;
|
|
497
|
+
private _recorder;
|
|
442
498
|
private _closed;
|
|
499
|
+
private _sentAudioChunks;
|
|
500
|
+
private _audioRemainder;
|
|
443
501
|
constructor(options?: GeminiRealtimeOptions);
|
|
502
|
+
/** Inject per-call ToolRegistry. */
|
|
503
|
+
setToolRegistry(registry: ToolRegistry): void;
|
|
504
|
+
/** Inject per-call AudioRecorder. */
|
|
505
|
+
setRecorder(recorder: AudioRecorder): void;
|
|
444
506
|
start(callSession: CallSession, tools?: ToolRegistry): Promise<void>;
|
|
445
507
|
feedAudio(audio: Buffer): void;
|
|
446
508
|
stop(): Promise<void>;
|
|
447
509
|
private _sendSetup;
|
|
510
|
+
private _waitSetupComplete;
|
|
511
|
+
private _sendGreeting;
|
|
512
|
+
private _receiveLoop;
|
|
448
513
|
private _handleMessage;
|
|
514
|
+
private _handleAudioData;
|
|
515
|
+
private _flushAudioRemainder;
|
|
449
516
|
private _handleToolCall;
|
|
450
517
|
}
|
|
451
518
|
|
|
@@ -459,6 +526,14 @@ interface PipelineSessionOptions {
|
|
|
459
526
|
tts: TTS;
|
|
460
527
|
/** System prompt for the LLM. */
|
|
461
528
|
systemPrompt?: string;
|
|
529
|
+
/** Send initial greeting. Default: true */
|
|
530
|
+
greeting?: boolean;
|
|
531
|
+
/** Language code. Default: 'ko' */
|
|
532
|
+
language?: string;
|
|
533
|
+
/** Tool registry for function calling. */
|
|
534
|
+
toolRegistry?: ToolRegistry;
|
|
535
|
+
/** Audio recorder for the session. */
|
|
536
|
+
recorder?: AudioRecorder;
|
|
462
537
|
/** LLM temperature. */
|
|
463
538
|
temperature?: number;
|
|
464
539
|
/** Max tokens for LLM generation. */
|
|
@@ -473,23 +548,30 @@ declare class PipelineSession implements Session {
|
|
|
473
548
|
private _llm;
|
|
474
549
|
private _tts;
|
|
475
550
|
private _systemPrompt;
|
|
551
|
+
private _greeting;
|
|
552
|
+
private _language;
|
|
476
553
|
private _temperature;
|
|
477
554
|
private _maxTokens;
|
|
478
555
|
private _sampleRate;
|
|
479
556
|
private _interruptOnSpeech;
|
|
480
557
|
private _callSession;
|
|
481
558
|
private _tools;
|
|
559
|
+
private _recorder;
|
|
482
560
|
private _conversation;
|
|
483
561
|
private _audioBuffer;
|
|
484
562
|
private _running;
|
|
485
563
|
private _speaking;
|
|
486
564
|
constructor(options: PipelineSessionOptions);
|
|
565
|
+
setToolRegistry(registry: ToolRegistry): void;
|
|
566
|
+
setRecorder(recorder: AudioRecorder): void;
|
|
487
567
|
start(callSession: CallSession, tools?: ToolRegistry): Promise<void>;
|
|
488
568
|
feedAudio(audio: Buffer): void;
|
|
489
569
|
stop(): Promise<void>;
|
|
490
570
|
private _runSttLoop;
|
|
491
571
|
private _createAudioStream;
|
|
572
|
+
private _generateGreeting;
|
|
492
573
|
private _handleUserSpeech;
|
|
574
|
+
private _respond;
|
|
493
575
|
private _handleToolCall;
|
|
494
576
|
private _synthesizeAndSend;
|
|
495
577
|
}
|
|
@@ -501,22 +583,22 @@ declare class PipelineSession implements Session {
|
|
|
501
583
|
interface DeepgramSTTOptions {
|
|
502
584
|
/** Deepgram API key. Falls back to DEEPGRAM_API_KEY env var. */
|
|
503
585
|
apiKey?: string;
|
|
504
|
-
/** Model to use. Default: 'nova-
|
|
586
|
+
/** Model to use. Default: 'nova-3' */
|
|
505
587
|
model?: string;
|
|
506
588
|
/** Language code. Default: 'ko' */
|
|
507
589
|
language?: string;
|
|
508
|
-
/**
|
|
509
|
-
|
|
510
|
-
/** Enable punctuation. Default: true */
|
|
511
|
-
punctuate?: boolean;
|
|
512
|
-
/** Enable smart formatting. Default: true */
|
|
513
|
-
smartFormat?: boolean;
|
|
590
|
+
/** Sample rate. Default: 16000 */
|
|
591
|
+
sampleRate?: number;
|
|
514
592
|
/** Encoding. Default: 'linear16' */
|
|
515
593
|
encoding?: string;
|
|
516
|
-
/**
|
|
517
|
-
|
|
518
|
-
/**
|
|
519
|
-
|
|
594
|
+
/** Enable punctuation. Default: true */
|
|
595
|
+
punctuate?: boolean;
|
|
596
|
+
/** Enable interim results. Default: true */
|
|
597
|
+
interimResults?: boolean;
|
|
598
|
+
/** Endpointing timeout in ms. Default: 300 */
|
|
599
|
+
endpointing?: number;
|
|
600
|
+
/** Utterance end silence timeout in ms. Default: 1000 */
|
|
601
|
+
utteranceEndMs?: number;
|
|
520
602
|
}
|
|
521
603
|
declare class DeepgramSTT implements STT {
|
|
522
604
|
private _options;
|
|
@@ -534,20 +616,18 @@ declare class DeepgramSTT implements STT {
|
|
|
534
616
|
interface ElevenLabsTTSOptions {
|
|
535
617
|
/** ElevenLabs API key. Falls back to ELEVENLABS_API_KEY env var. */
|
|
536
618
|
apiKey?: string;
|
|
537
|
-
/** Voice ID. Default: '
|
|
619
|
+
/** Voice ID. Default: 'EXAVITQu4vr4xnSDxMaL' (Rachel) */
|
|
538
620
|
voiceId?: string;
|
|
539
|
-
/** Model ID. Default: '
|
|
540
|
-
|
|
541
|
-
/** Output format. Default: '
|
|
621
|
+
/** Model ID. Default: 'eleven_flash_v2_5' */
|
|
622
|
+
model?: string;
|
|
623
|
+
/** Output format. Default: 'pcm_24000' */
|
|
542
624
|
outputFormat?: string;
|
|
543
625
|
/** Stability. Default: 0.5 */
|
|
544
626
|
stability?: number;
|
|
545
627
|
/** Similarity boost. Default: 0.75 */
|
|
546
628
|
similarityBoost?: number;
|
|
547
|
-
/**
|
|
548
|
-
|
|
549
|
-
/** Use speaker boost. Default: true */
|
|
550
|
-
useSpeakerBoost?: boolean;
|
|
629
|
+
/** Language code. Default: 'ko' */
|
|
630
|
+
languageCode?: string;
|
|
551
631
|
}
|
|
552
632
|
declare class ElevenLabsTTS implements TTS {
|
|
553
633
|
private _options;
|
|
@@ -567,11 +647,11 @@ declare class ElevenLabsTTS implements TTS {
|
|
|
567
647
|
interface OpenAILLMOptions {
|
|
568
648
|
/** OpenAI API key. Falls back to OPENAI_API_KEY env var. */
|
|
569
649
|
apiKey?: string;
|
|
570
|
-
/** Model to use. Default: 'gpt-4o' */
|
|
650
|
+
/** Model to use. Default: 'gpt-4o-mini' */
|
|
571
651
|
model?: string;
|
|
572
|
-
/** Default temperature. */
|
|
652
|
+
/** Default temperature. Default: 0.8 */
|
|
573
653
|
temperature?: number;
|
|
574
|
-
/** Default max tokens. */
|
|
654
|
+
/** Default max tokens. Default: 4096 */
|
|
575
655
|
maxTokens?: number;
|
|
576
656
|
}
|
|
577
657
|
declare class OpenAILLM implements LLM {
|
|
@@ -591,11 +671,11 @@ declare class OpenAILLM implements LLM {
|
|
|
591
671
|
interface AnthropicLLMOptions {
|
|
592
672
|
/** Anthropic API key. Falls back to ANTHROPIC_API_KEY env var. */
|
|
593
673
|
apiKey?: string;
|
|
594
|
-
/** Model to use. Default: 'claude-sonnet-4-
|
|
674
|
+
/** Model to use. Default: 'claude-sonnet-4-6' */
|
|
595
675
|
model?: string;
|
|
596
|
-
/** Default temperature. */
|
|
676
|
+
/** Default temperature. Default: 0.8 */
|
|
597
677
|
temperature?: number;
|
|
598
|
-
/** Default max tokens. Default:
|
|
678
|
+
/** Default max tokens. Default: 4096 */
|
|
599
679
|
maxTokens?: number;
|
|
600
680
|
}
|
|
601
681
|
declare class AnthropicLLM implements LLM {
|
|
@@ -615,11 +695,11 @@ declare class AnthropicLLM implements LLM {
|
|
|
615
695
|
interface GeminiLLMOptions {
|
|
616
696
|
/** Google API key. Falls back to GOOGLE_API_KEY env var. */
|
|
617
697
|
apiKey?: string;
|
|
618
|
-
/** Model to use. Default: 'gemini-2.
|
|
698
|
+
/** Model to use. Default: 'gemini-2.5-flash' */
|
|
619
699
|
model?: string;
|
|
620
|
-
/** Default temperature. */
|
|
700
|
+
/** Default temperature. Default: 0.8 */
|
|
621
701
|
temperature?: number;
|
|
622
|
-
/** Default max tokens. */
|
|
702
|
+
/** Default max tokens. Default: 4096 */
|
|
623
703
|
maxTokens?: number;
|
|
624
704
|
}
|
|
625
705
|
declare class GeminiLLM implements LLM {
|
|
@@ -666,13 +746,13 @@ declare class OpenAICompatLLM implements LLM {
|
|
|
666
746
|
*/
|
|
667
747
|
|
|
668
748
|
interface OllamaLLMOptions {
|
|
669
|
-
/** Ollama server URL. Default: 'http://localhost:11434' */
|
|
749
|
+
/** Ollama server URL. Falls back to OLLAMA_BASE_URL env var. Default: 'http://localhost:11434/v1' */
|
|
670
750
|
baseUrl?: string;
|
|
671
|
-
/** Model to use. Default: 'llama3.
|
|
751
|
+
/** Model to use. Default: 'llama3.2' */
|
|
672
752
|
model?: string;
|
|
673
|
-
/** Default temperature. */
|
|
753
|
+
/** Default temperature. Default: 0.8 */
|
|
674
754
|
temperature?: number;
|
|
675
|
-
/** Default max tokens. */
|
|
755
|
+
/** Default max tokens. Default: 4096 */
|
|
676
756
|
maxTokens?: number;
|
|
677
757
|
}
|
|
678
758
|
declare class OllamaLLM implements LLM {
|
|
@@ -797,25 +877,4 @@ declare class XaiLLM implements LLM {
|
|
|
797
877
|
}): AsyncGenerator<LLMChunk>;
|
|
798
878
|
}
|
|
799
879
|
|
|
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 };
|
|
880
|
+
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 STT, type Session, type SpeechEvent, type TTS, TogetherLLM, type TogetherLLMOptions, ToolRegistry, type TracingConfig, XaiLLM, type XaiLLMOptions, functionTool, getTracingConfig, mcpServerHTTP, mcpServerStdio, pcm16ToUlaw, resamplePcm16, resetTracingConfig, setTracingConfig, ulawToPcm16, zodToToolParams };
|