@teamlearners/clawops 0.5.4 → 0.5.8

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.
@@ -470,6 +470,72 @@ declare class AudioRecorder {
470
470
  stop(): void;
471
471
  }
472
472
 
473
+ /**
474
+ * PipelineSession orchestrates STT -> LLM -> TTS for a voice call.
475
+ */
476
+
477
+ interface PipelineSessionOptions {
478
+ stt: STT;
479
+ llm: LLM;
480
+ tts: TTS;
481
+ /** System prompt for the LLM. */
482
+ systemPrompt?: string;
483
+ /** Send initial greeting. Default: true */
484
+ greeting?: boolean;
485
+ /** Language code. Default: 'ko' */
486
+ language?: string;
487
+ /** Tool registry for function calling. */
488
+ toolRegistry?: ToolRegistry;
489
+ /** Audio recorder for the session. */
490
+ recorder?: AudioRecorder;
491
+ /** LLM temperature. */
492
+ temperature?: number;
493
+ /** Max tokens for LLM generation. */
494
+ maxTokens?: number;
495
+ /** Sample rate for audio. Default: 8000 */
496
+ sampleRate?: number;
497
+ /** Whether to interrupt TTS when user starts speaking. Default: true */
498
+ interruptOnSpeech?: boolean;
499
+ }
500
+ declare class PipelineSession implements Session {
501
+ private _stt;
502
+ private _llm;
503
+ private _tts;
504
+ private _systemPrompt;
505
+ private _greeting;
506
+ private _language;
507
+ private _temperature;
508
+ private _maxTokens;
509
+ private _sampleRate;
510
+ private _interruptOnSpeech;
511
+ private _callSession;
512
+ private _tools;
513
+ private _recorder;
514
+ private _conversation;
515
+ private _audioBuffer;
516
+ private _running;
517
+ private _speaking;
518
+ private _builtinTools;
519
+ private _log;
520
+ constructor(options: PipelineSessionOptions);
521
+ setToolRegistry(registry: ToolRegistry): void;
522
+ setRecorder(recorder: AudioRecorder): void;
523
+ setBuiltinTools(tools: Set<BuiltinTool>): void;
524
+ setLogger(logger: Logger): void;
525
+ start(callSession: CallSession, tools?: ToolRegistry): Promise<void>;
526
+ feedAudio(audio: Buffer): void;
527
+ feedDtmf(digits: string): Promise<void>;
528
+ stop(): Promise<void>;
529
+ private _runSttLoop;
530
+ private _createAudioStream;
531
+ private _generateGreeting;
532
+ private _handleUserSpeech;
533
+ private _buildEffectiveTools;
534
+ private _respond;
535
+ private _handleToolCall;
536
+ private _synthesizeAndSend;
537
+ }
538
+
473
539
  /**
474
540
  * OpenAI Realtime API session (speech-to-speech).
475
541
  *
@@ -487,8 +553,13 @@ interface OpenAIRealtimeOptions {
487
553
  voice?: string;
488
554
  /** Language code (BCP 47). Default: 'ko' */
489
555
  language?: string;
490
- /** VAD eagerness: 'low', 'medium', 'high'. Default: 'high' */
491
- eagerness?: string;
556
+ /**
557
+ * Turn detection configuration. Default: semantic_vad with eagerness 'medium'.
558
+ * - `{ type: 'semantic_vad', eagerness?: 'low'|'medium'|'high'|'auto', interrupt_response?: boolean }`
559
+ * - `{ type: 'server_vad', threshold?: number, silence_duration_ms?: number, prefix_padding_ms?: number }`
560
+ * - `null` to disable turn detection
561
+ */
562
+ turnDetection?: Record<string, unknown> | null;
492
563
  /** Send initial greeting. Default: true */
493
564
  greeting?: boolean;
494
565
  }
@@ -498,7 +569,7 @@ declare class OpenAIRealtime implements Session {
498
569
  private _model;
499
570
  private _voice;
500
571
  private _language;
501
- private _eagerness;
572
+ private _turnDetection;
502
573
  private _greeting;
503
574
  private _log;
504
575
  private _builtinTools;
@@ -509,10 +580,9 @@ declare class OpenAIRealtime implements Session {
509
580
  private _tools;
510
581
  private _recorder;
511
582
  private _closed;
512
- private _lastAssistantItem;
513
- private _responseStartTs;
514
- private _sentAudioChunks;
515
- private _audioRemainder;
583
+ private _playback;
584
+ private _latestMediaTs;
585
+ private _pendingToolCalls;
516
586
  private _responseInProgress;
517
587
  private _onResponseDone;
518
588
  constructor(options?: OpenAIRealtimeOptions);
@@ -589,72 +659,6 @@ declare class GeminiRealtime implements Session {
589
659
  private _handleToolCall;
590
660
  }
591
661
 
592
- /**
593
- * PipelineSession orchestrates STT -> LLM -> TTS for a voice call.
594
- */
595
-
596
- interface PipelineSessionOptions {
597
- stt: STT;
598
- llm: LLM;
599
- tts: TTS;
600
- /** System prompt for the LLM. */
601
- systemPrompt?: string;
602
- /** Send initial greeting. Default: true */
603
- greeting?: boolean;
604
- /** Language code. Default: 'ko' */
605
- language?: string;
606
- /** Tool registry for function calling. */
607
- toolRegistry?: ToolRegistry;
608
- /** Audio recorder for the session. */
609
- recorder?: AudioRecorder;
610
- /** LLM temperature. */
611
- temperature?: number;
612
- /** Max tokens for LLM generation. */
613
- maxTokens?: number;
614
- /** Sample rate for audio. Default: 8000 */
615
- sampleRate?: number;
616
- /** Whether to interrupt TTS when user starts speaking. Default: true */
617
- interruptOnSpeech?: boolean;
618
- }
619
- declare class PipelineSession implements Session {
620
- private _stt;
621
- private _llm;
622
- private _tts;
623
- private _systemPrompt;
624
- private _greeting;
625
- private _language;
626
- private _temperature;
627
- private _maxTokens;
628
- private _sampleRate;
629
- private _interruptOnSpeech;
630
- private _callSession;
631
- private _tools;
632
- private _recorder;
633
- private _conversation;
634
- private _audioBuffer;
635
- private _running;
636
- private _speaking;
637
- private _builtinTools;
638
- private _log;
639
- constructor(options: PipelineSessionOptions);
640
- setToolRegistry(registry: ToolRegistry): void;
641
- setRecorder(recorder: AudioRecorder): void;
642
- setBuiltinTools(tools: Set<BuiltinTool>): void;
643
- setLogger(logger: Logger): void;
644
- start(callSession: CallSession, tools?: ToolRegistry): Promise<void>;
645
- feedAudio(audio: Buffer): void;
646
- feedDtmf(digits: string): Promise<void>;
647
- stop(): Promise<void>;
648
- private _runSttLoop;
649
- private _createAudioStream;
650
- private _generateGreeting;
651
- private _handleUserSpeech;
652
- private _buildEffectiveTools;
653
- private _respond;
654
- private _handleToolCall;
655
- private _synthesizeAndSend;
656
- }
657
-
658
662
  /**
659
663
  * Deepgram STT (Speech-to-Text) provider.
660
664
  */
@@ -960,6 +964,27 @@ declare class XaiLLM implements LLM {
960
964
  }): AsyncGenerator<LLMChunk>;
961
965
  }
962
966
 
967
+ /**
968
+ * Built-in tool 스키마 정의, 포맷 변환, 실행 헬퍼.
969
+ *
970
+ * 모든 세션(PipelineSession, OpenAIRealtime, GeminiRealtime)이 공통으로 사용하는
971
+ * 내장 도구 스키마를 한 곳에서 관리한다.
972
+ */
973
+
974
+ declare const BUILTIN_TOOL_NAMES: Set<string>;
975
+ /**
976
+ * 활성화된 builtin tool 스키마를 요청한 포맷으로 반환.
977
+ */
978
+ declare function getBuiltinToolSchemas(builtinTools: Set<BuiltinTool> | null, fmt: 'chat' | 'realtime' | 'gemini'): Array<Record<string, unknown>>;
979
+ /**
980
+ * Builtin tool을 실행하고 결과 문자열을 반환한다.
981
+ *
982
+ * `funcName`이 builtin tool이 아니면 `null`을 반환한다.
983
+ * `hang_up`의 경우 빈 문자열 `""`을 반환한다 (호출자가 종료 처리).
984
+ */
985
+ declare function isBuiltinTool(name: string): boolean;
986
+ declare function executeBuiltinTool(funcName: string, args: Record<string, unknown>, call: CallSession): Promise<string | null>;
987
+
963
988
  /**
964
989
  * Logger factory for the ClawOps agent module.
965
990
  *
@@ -979,4 +1004,4 @@ declare function createAgentLogger(userLogger?: Logger): Logger;
979
1004
  */
980
1005
  declare function createPipelineLogger(parent: Logger): Logger;
981
1006
 
982
- export { type AgentEventType, AnthropicLLM, type AnthropicLLMOptions, AudioRecorder, BuiltinTool, 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, createAgentLogger, createPipelineLogger, functionTool, getTracingConfig, mcpServerHTTP, mcpServerStdio, pcm16ToUlaw, resamplePcm16, resetTracingConfig, setTracingConfig, ulawToPcm16, zodToToolParams };
1007
+ export { type AgentEventType, AnthropicLLM, type AnthropicLLMOptions, AudioRecorder, BUILTIN_TOOL_NAMES, BuiltinTool, 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, type ToolCallRequest, ToolRegistry, type TracingConfig, XaiLLM, type XaiLLMOptions, createAgentLogger, createPipelineLogger, executeBuiltinTool, functionTool, getBuiltinToolSchemas, getTracingConfig, isBuiltinTool, mcpServerHTTP, mcpServerStdio, pcm16ToUlaw, resamplePcm16, resetTracingConfig, setTracingConfig, ulawToPcm16, zodToToolParams };
@@ -470,6 +470,72 @@ declare class AudioRecorder {
470
470
  stop(): void;
471
471
  }
472
472
 
473
+ /**
474
+ * PipelineSession orchestrates STT -> LLM -> TTS for a voice call.
475
+ */
476
+
477
+ interface PipelineSessionOptions {
478
+ stt: STT;
479
+ llm: LLM;
480
+ tts: TTS;
481
+ /** System prompt for the LLM. */
482
+ systemPrompt?: string;
483
+ /** Send initial greeting. Default: true */
484
+ greeting?: boolean;
485
+ /** Language code. Default: 'ko' */
486
+ language?: string;
487
+ /** Tool registry for function calling. */
488
+ toolRegistry?: ToolRegistry;
489
+ /** Audio recorder for the session. */
490
+ recorder?: AudioRecorder;
491
+ /** LLM temperature. */
492
+ temperature?: number;
493
+ /** Max tokens for LLM generation. */
494
+ maxTokens?: number;
495
+ /** Sample rate for audio. Default: 8000 */
496
+ sampleRate?: number;
497
+ /** Whether to interrupt TTS when user starts speaking. Default: true */
498
+ interruptOnSpeech?: boolean;
499
+ }
500
+ declare class PipelineSession implements Session {
501
+ private _stt;
502
+ private _llm;
503
+ private _tts;
504
+ private _systemPrompt;
505
+ private _greeting;
506
+ private _language;
507
+ private _temperature;
508
+ private _maxTokens;
509
+ private _sampleRate;
510
+ private _interruptOnSpeech;
511
+ private _callSession;
512
+ private _tools;
513
+ private _recorder;
514
+ private _conversation;
515
+ private _audioBuffer;
516
+ private _running;
517
+ private _speaking;
518
+ private _builtinTools;
519
+ private _log;
520
+ constructor(options: PipelineSessionOptions);
521
+ setToolRegistry(registry: ToolRegistry): void;
522
+ setRecorder(recorder: AudioRecorder): void;
523
+ setBuiltinTools(tools: Set<BuiltinTool>): void;
524
+ setLogger(logger: Logger): void;
525
+ start(callSession: CallSession, tools?: ToolRegistry): Promise<void>;
526
+ feedAudio(audio: Buffer): void;
527
+ feedDtmf(digits: string): Promise<void>;
528
+ stop(): Promise<void>;
529
+ private _runSttLoop;
530
+ private _createAudioStream;
531
+ private _generateGreeting;
532
+ private _handleUserSpeech;
533
+ private _buildEffectiveTools;
534
+ private _respond;
535
+ private _handleToolCall;
536
+ private _synthesizeAndSend;
537
+ }
538
+
473
539
  /**
474
540
  * OpenAI Realtime API session (speech-to-speech).
475
541
  *
@@ -487,8 +553,13 @@ interface OpenAIRealtimeOptions {
487
553
  voice?: string;
488
554
  /** Language code (BCP 47). Default: 'ko' */
489
555
  language?: string;
490
- /** VAD eagerness: 'low', 'medium', 'high'. Default: 'high' */
491
- eagerness?: string;
556
+ /**
557
+ * Turn detection configuration. Default: semantic_vad with eagerness 'medium'.
558
+ * - `{ type: 'semantic_vad', eagerness?: 'low'|'medium'|'high'|'auto', interrupt_response?: boolean }`
559
+ * - `{ type: 'server_vad', threshold?: number, silence_duration_ms?: number, prefix_padding_ms?: number }`
560
+ * - `null` to disable turn detection
561
+ */
562
+ turnDetection?: Record<string, unknown> | null;
492
563
  /** Send initial greeting. Default: true */
493
564
  greeting?: boolean;
494
565
  }
@@ -498,7 +569,7 @@ declare class OpenAIRealtime implements Session {
498
569
  private _model;
499
570
  private _voice;
500
571
  private _language;
501
- private _eagerness;
572
+ private _turnDetection;
502
573
  private _greeting;
503
574
  private _log;
504
575
  private _builtinTools;
@@ -509,10 +580,9 @@ declare class OpenAIRealtime implements Session {
509
580
  private _tools;
510
581
  private _recorder;
511
582
  private _closed;
512
- private _lastAssistantItem;
513
- private _responseStartTs;
514
- private _sentAudioChunks;
515
- private _audioRemainder;
583
+ private _playback;
584
+ private _latestMediaTs;
585
+ private _pendingToolCalls;
516
586
  private _responseInProgress;
517
587
  private _onResponseDone;
518
588
  constructor(options?: OpenAIRealtimeOptions);
@@ -589,72 +659,6 @@ declare class GeminiRealtime implements Session {
589
659
  private _handleToolCall;
590
660
  }
591
661
 
592
- /**
593
- * PipelineSession orchestrates STT -> LLM -> TTS for a voice call.
594
- */
595
-
596
- interface PipelineSessionOptions {
597
- stt: STT;
598
- llm: LLM;
599
- tts: TTS;
600
- /** System prompt for the LLM. */
601
- systemPrompt?: string;
602
- /** Send initial greeting. Default: true */
603
- greeting?: boolean;
604
- /** Language code. Default: 'ko' */
605
- language?: string;
606
- /** Tool registry for function calling. */
607
- toolRegistry?: ToolRegistry;
608
- /** Audio recorder for the session. */
609
- recorder?: AudioRecorder;
610
- /** LLM temperature. */
611
- temperature?: number;
612
- /** Max tokens for LLM generation. */
613
- maxTokens?: number;
614
- /** Sample rate for audio. Default: 8000 */
615
- sampleRate?: number;
616
- /** Whether to interrupt TTS when user starts speaking. Default: true */
617
- interruptOnSpeech?: boolean;
618
- }
619
- declare class PipelineSession implements Session {
620
- private _stt;
621
- private _llm;
622
- private _tts;
623
- private _systemPrompt;
624
- private _greeting;
625
- private _language;
626
- private _temperature;
627
- private _maxTokens;
628
- private _sampleRate;
629
- private _interruptOnSpeech;
630
- private _callSession;
631
- private _tools;
632
- private _recorder;
633
- private _conversation;
634
- private _audioBuffer;
635
- private _running;
636
- private _speaking;
637
- private _builtinTools;
638
- private _log;
639
- constructor(options: PipelineSessionOptions);
640
- setToolRegistry(registry: ToolRegistry): void;
641
- setRecorder(recorder: AudioRecorder): void;
642
- setBuiltinTools(tools: Set<BuiltinTool>): void;
643
- setLogger(logger: Logger): void;
644
- start(callSession: CallSession, tools?: ToolRegistry): Promise<void>;
645
- feedAudio(audio: Buffer): void;
646
- feedDtmf(digits: string): Promise<void>;
647
- stop(): Promise<void>;
648
- private _runSttLoop;
649
- private _createAudioStream;
650
- private _generateGreeting;
651
- private _handleUserSpeech;
652
- private _buildEffectiveTools;
653
- private _respond;
654
- private _handleToolCall;
655
- private _synthesizeAndSend;
656
- }
657
-
658
662
  /**
659
663
  * Deepgram STT (Speech-to-Text) provider.
660
664
  */
@@ -960,6 +964,27 @@ declare class XaiLLM implements LLM {
960
964
  }): AsyncGenerator<LLMChunk>;
961
965
  }
962
966
 
967
+ /**
968
+ * Built-in tool 스키마 정의, 포맷 변환, 실행 헬퍼.
969
+ *
970
+ * 모든 세션(PipelineSession, OpenAIRealtime, GeminiRealtime)이 공통으로 사용하는
971
+ * 내장 도구 스키마를 한 곳에서 관리한다.
972
+ */
973
+
974
+ declare const BUILTIN_TOOL_NAMES: Set<string>;
975
+ /**
976
+ * 활성화된 builtin tool 스키마를 요청한 포맷으로 반환.
977
+ */
978
+ declare function getBuiltinToolSchemas(builtinTools: Set<BuiltinTool> | null, fmt: 'chat' | 'realtime' | 'gemini'): Array<Record<string, unknown>>;
979
+ /**
980
+ * Builtin tool을 실행하고 결과 문자열을 반환한다.
981
+ *
982
+ * `funcName`이 builtin tool이 아니면 `null`을 반환한다.
983
+ * `hang_up`의 경우 빈 문자열 `""`을 반환한다 (호출자가 종료 처리).
984
+ */
985
+ declare function isBuiltinTool(name: string): boolean;
986
+ declare function executeBuiltinTool(funcName: string, args: Record<string, unknown>, call: CallSession): Promise<string | null>;
987
+
963
988
  /**
964
989
  * Logger factory for the ClawOps agent module.
965
990
  *
@@ -979,4 +1004,4 @@ declare function createAgentLogger(userLogger?: Logger): Logger;
979
1004
  */
980
1005
  declare function createPipelineLogger(parent: Logger): Logger;
981
1006
 
982
- export { type AgentEventType, AnthropicLLM, type AnthropicLLMOptions, AudioRecorder, BuiltinTool, 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, createAgentLogger, createPipelineLogger, functionTool, getTracingConfig, mcpServerHTTP, mcpServerStdio, pcm16ToUlaw, resamplePcm16, resetTracingConfig, setTracingConfig, ulawToPcm16, zodToToolParams };
1007
+ export { type AgentEventType, AnthropicLLM, type AnthropicLLMOptions, AudioRecorder, BUILTIN_TOOL_NAMES, BuiltinTool, 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, type ToolCallRequest, ToolRegistry, type TracingConfig, XaiLLM, type XaiLLMOptions, createAgentLogger, createPipelineLogger, executeBuiltinTool, functionTool, getBuiltinToolSchemas, getTracingConfig, isBuiltinTool, mcpServerHTTP, mcpServerStdio, pcm16ToUlaw, resamplePcm16, resetTracingConfig, setTracingConfig, ulawToPcm16, zodToToolParams };