@teamlearners/clawops 0.16.4 → 0.16.6

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.
@@ -517,6 +517,64 @@ declare class ClawOpsAgent {
517
517
  private _startCallSession;
518
518
  }
519
519
 
520
+ /**
521
+ * Control WebSocket for agent signaling (call.incoming, call.ended, etc.).
522
+ */
523
+
524
+ interface ControlWsOptions {
525
+ baseUrl: string;
526
+ apiKey: string;
527
+ accountId: string;
528
+ /** Phone number to register on. */
529
+ number?: string;
530
+ }
531
+ /**
532
+ * Control event is a flat JSON object with an 'event' field.
533
+ * Example: { "event": "call.incoming", "callId": "xxx", "from": "070...", "mediaUrl": "wss://..." }
534
+ */
535
+ interface ControlEvent {
536
+ event: string;
537
+ [key: string]: unknown;
538
+ }
539
+ type ControlEventHandler = (event: ControlEvent) => void | Promise<void>;
540
+ /**
541
+ * Build the full control WebSocket URL from options.
542
+ * Matches Python SDK: /v1/accounts/{account_id}/agent/listen?number={number}
543
+ */
544
+ declare function buildControlWsUrl(options: ControlWsOptions): string;
545
+ declare class ControlWebSocket {
546
+ private readonly _options;
547
+ private _url;
548
+ private _ws;
549
+ private _handlers;
550
+ private _transferResolvers;
551
+ private _reconnectDelay;
552
+ private _closed;
553
+ private _connectedResolve;
554
+ private _connectedPromise;
555
+ private _log;
556
+ private _pingTimer;
557
+ setLogger(logger: Logger): void;
558
+ constructor(_options: ControlWsOptions);
559
+ /** Register an event handler for a specific event type. */
560
+ on(event: string, handler: ControlEventHandler): void;
561
+ /** Connect to the control WebSocket. */
562
+ connect(): Promise<void>;
563
+ /** Wait until the WebSocket is connected. */
564
+ waitConnected(): Promise<void>;
565
+ /** Request a call transfer and wait for the result. */
566
+ requestTransfer(callId: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
567
+ /** Send a JSON message over the control WebSocket. */
568
+ send(message: Record<string, unknown>): void;
569
+ /** Close the WebSocket and stop reconnecting. */
570
+ close(): void;
571
+ private _doConnect;
572
+ private _dispatchEvent;
573
+ private _resetPingTimer;
574
+ private _clearPingTimer;
575
+ private _scheduleReconnect;
576
+ }
577
+
520
578
  /**
521
579
  * Media WebSocket for streaming audio to/from the telephony platform.
522
580
  *
@@ -1202,4 +1260,4 @@ declare function createAgentLogger(userLogger?: Logger): Logger;
1202
1260
  */
1203
1261
  declare function createPipelineLogger(parent: Logger): Logger;
1204
1262
 
1205
- 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, type DtmfEvent, 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, type MediaEvent, type MediaStartEvent, MediaWebSocket, 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, type ToolConfig, ToolRegistry, type TracingConfig, XaiLLM, type XaiLLMOptions, createAgentLogger, createPipelineLogger, executeBuiltinTool, functionTool, getBuiltinToolSchemas, getTracingConfig, isBuiltinTool, mcpServerHTTP, mcpServerStdio, pcm16ToUlaw, resamplePcm16, resetTracingConfig, setTracingConfig, ulawToPcm16, zodToToolParams };
1263
+ export { type AgentEventType, AnthropicLLM, type AnthropicLLMOptions, AudioRecorder, BUILTIN_TOOL_NAMES, BuiltinTool, type CallDirection, CallSession, type CallStatus, ClawOpsAgent, type ClawOpsAgentOptions, type ControlEvent, ControlWebSocket, type ControlWsOptions, type ConversationMessage, DECODE_TABLE, DeepSeekLLM, type DeepSeekLLMOptions, DeepgramSTT, type DeepgramSTTOptions, type DtmfEvent, 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, type MediaEvent, type MediaStartEvent, MediaWebSocket, 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, type ToolConfig, ToolRegistry, type TracingConfig, XaiLLM, type XaiLLMOptions, buildControlWsUrl, createAgentLogger, createPipelineLogger, executeBuiltinTool, functionTool, getBuiltinToolSchemas, getTracingConfig, isBuiltinTool, mcpServerHTTP, mcpServerStdio, pcm16ToUlaw, resamplePcm16, resetTracingConfig, setTracingConfig, ulawToPcm16, zodToToolParams };
@@ -517,6 +517,64 @@ declare class ClawOpsAgent {
517
517
  private _startCallSession;
518
518
  }
519
519
 
520
+ /**
521
+ * Control WebSocket for agent signaling (call.incoming, call.ended, etc.).
522
+ */
523
+
524
+ interface ControlWsOptions {
525
+ baseUrl: string;
526
+ apiKey: string;
527
+ accountId: string;
528
+ /** Phone number to register on. */
529
+ number?: string;
530
+ }
531
+ /**
532
+ * Control event is a flat JSON object with an 'event' field.
533
+ * Example: { "event": "call.incoming", "callId": "xxx", "from": "070...", "mediaUrl": "wss://..." }
534
+ */
535
+ interface ControlEvent {
536
+ event: string;
537
+ [key: string]: unknown;
538
+ }
539
+ type ControlEventHandler = (event: ControlEvent) => void | Promise<void>;
540
+ /**
541
+ * Build the full control WebSocket URL from options.
542
+ * Matches Python SDK: /v1/accounts/{account_id}/agent/listen?number={number}
543
+ */
544
+ declare function buildControlWsUrl(options: ControlWsOptions): string;
545
+ declare class ControlWebSocket {
546
+ private readonly _options;
547
+ private _url;
548
+ private _ws;
549
+ private _handlers;
550
+ private _transferResolvers;
551
+ private _reconnectDelay;
552
+ private _closed;
553
+ private _connectedResolve;
554
+ private _connectedPromise;
555
+ private _log;
556
+ private _pingTimer;
557
+ setLogger(logger: Logger): void;
558
+ constructor(_options: ControlWsOptions);
559
+ /** Register an event handler for a specific event type. */
560
+ on(event: string, handler: ControlEventHandler): void;
561
+ /** Connect to the control WebSocket. */
562
+ connect(): Promise<void>;
563
+ /** Wait until the WebSocket is connected. */
564
+ waitConnected(): Promise<void>;
565
+ /** Request a call transfer and wait for the result. */
566
+ requestTransfer(callId: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
567
+ /** Send a JSON message over the control WebSocket. */
568
+ send(message: Record<string, unknown>): void;
569
+ /** Close the WebSocket and stop reconnecting. */
570
+ close(): void;
571
+ private _doConnect;
572
+ private _dispatchEvent;
573
+ private _resetPingTimer;
574
+ private _clearPingTimer;
575
+ private _scheduleReconnect;
576
+ }
577
+
520
578
  /**
521
579
  * Media WebSocket for streaming audio to/from the telephony platform.
522
580
  *
@@ -1202,4 +1260,4 @@ declare function createAgentLogger(userLogger?: Logger): Logger;
1202
1260
  */
1203
1261
  declare function createPipelineLogger(parent: Logger): Logger;
1204
1262
 
1205
- 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, type DtmfEvent, 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, type MediaEvent, type MediaStartEvent, MediaWebSocket, 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, type ToolConfig, ToolRegistry, type TracingConfig, XaiLLM, type XaiLLMOptions, createAgentLogger, createPipelineLogger, executeBuiltinTool, functionTool, getBuiltinToolSchemas, getTracingConfig, isBuiltinTool, mcpServerHTTP, mcpServerStdio, pcm16ToUlaw, resamplePcm16, resetTracingConfig, setTracingConfig, ulawToPcm16, zodToToolParams };
1263
+ export { type AgentEventType, AnthropicLLM, type AnthropicLLMOptions, AudioRecorder, BUILTIN_TOOL_NAMES, BuiltinTool, type CallDirection, CallSession, type CallStatus, ClawOpsAgent, type ClawOpsAgentOptions, type ControlEvent, ControlWebSocket, type ControlWsOptions, type ConversationMessage, DECODE_TABLE, DeepSeekLLM, type DeepSeekLLMOptions, DeepgramSTT, type DeepgramSTTOptions, type DtmfEvent, 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, type MediaEvent, type MediaStartEvent, MediaWebSocket, 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, type ToolConfig, ToolRegistry, type TracingConfig, XaiLLM, type XaiLLMOptions, buildControlWsUrl, createAgentLogger, createPipelineLogger, executeBuiltinTool, functionTool, getBuiltinToolSchemas, getTracingConfig, isBuiltinTool, mcpServerHTTP, mcpServerStdio, pcm16ToUlaw, resamplePcm16, resetTracingConfig, setTracingConfig, ulawToPcm16, zodToToolParams };
@@ -1,4 +1,4 @@
1
- import { DEFAULT_BASE_URL, AgentError, AgentConnectionError, VERSION } from '../chunk-B3SD2KKR.js';
1
+ import { DEFAULT_BASE_URL, AgentError, AgentConnectionError, VERSION } from '../chunk-RYJF2N7K.js';
2
2
  import pino from 'pino';
3
3
  import * as fs from 'fs';
4
4
  import * as path from 'path';
@@ -2689,8 +2689,7 @@ var OpenAIRealtime = class {
2689
2689
  const url = `${OPENAI_REALTIME_URL}${this._model}`;
2690
2690
  this._ws = new WebSocket(url, {
2691
2691
  headers: {
2692
- Authorization: `Bearer ${this._apiKey}`,
2693
- "OpenAI-Beta": "realtime=v1"
2692
+ Authorization: `Bearer ${this._apiKey}`
2694
2693
  }
2695
2694
  });
2696
2695
  return new Promise((resolve, reject) => {
@@ -2760,17 +2759,24 @@ var OpenAIRealtime = class {
2760
2759
  this._send({
2761
2760
  type: "session.update",
2762
2761
  session: {
2763
- modalities: ["text", "audio"],
2764
- voice: this._voice,
2762
+ type: "realtime",
2763
+ output_modalities: ["audio"],
2765
2764
  instructions: this._systemPrompt,
2766
- input_audio_format: "g711_ulaw",
2767
- output_audio_format: "g711_ulaw",
2768
- input_audio_transcription: {
2769
- model: "whisper-1",
2770
- language: this._language
2765
+ audio: {
2766
+ input: {
2767
+ format: { type: "audio/pcmu" },
2768
+ noise_reduction: { type: "far_field" },
2769
+ transcription: {
2770
+ model: "gpt-realtime-whisper",
2771
+ language: this._language
2772
+ },
2773
+ turn_detection: this._turnDetection
2774
+ },
2775
+ output: {
2776
+ format: { type: "audio/pcmu" },
2777
+ voice: this._voice
2778
+ }
2771
2779
  },
2772
- input_audio_noise_reduction: { type: "far_field" },
2773
- turn_detection: this._turnDetection,
2774
2780
  tools: toolSchemas
2775
2781
  }
2776
2782
  });
@@ -2778,11 +2784,11 @@ var OpenAIRealtime = class {
2778
2784
  _handleMessage(msg) {
2779
2785
  const type = msg["type"];
2780
2786
  switch (type) {
2781
- case "response.audio.delta": {
2787
+ case "response.output_audio.delta": {
2782
2788
  this._handleAudioDelta(msg);
2783
2789
  break;
2784
2790
  }
2785
- case "response.audio.done": {
2791
+ case "response.output_audio.done": {
2786
2792
  if (this._playback) {
2787
2793
  this._playback.generating = false;
2788
2794
  if (this._playback.audioRemainder.length > 0) {
@@ -2816,7 +2822,7 @@ var OpenAIRealtime = class {
2816
2822
  }
2817
2823
  break;
2818
2824
  }
2819
- case "response.audio_transcript.done": {
2825
+ case "response.output_audio_transcript.done": {
2820
2826
  if (this._call) {
2821
2827
  this._call._emit("transcript", "assistant", msg["transcript"] ?? "");
2822
2828
  }
@@ -4248,6 +4254,6 @@ function mcpServerHTTP(options) {
4248
4254
  };
4249
4255
  }
4250
4256
 
4251
- export { AnthropicLLM, AudioRecorder, BUILTIN_TOOL_NAMES, BuiltinTool, CallSession, ClawOpsAgent, DECODE_TABLE, DeepSeekLLM, DeepgramSTT, ElevenLabsTTS, FireworksLLM, GeminiLLM, GeminiRealtime, GroqLLM, MCPClient, MediaWebSocket, MistralLLM, OllamaLLM, OpenAICompatLLM, OpenAILLM, OpenAIRealtime, PerplexityLLM, PipelineSession, TogetherLLM, ToolRegistry, XaiLLM, createAgentLogger, createPipelineLogger, executeBuiltinTool, functionTool, getBuiltinToolSchemas, getTracingConfig, isBuiltinTool, mcpServerHTTP, mcpServerStdio, pcm16ToUlaw, resamplePcm16, resetTracingConfig, setTracingConfig, ulawToPcm16, zodToToolParams };
4257
+ export { AnthropicLLM, AudioRecorder, BUILTIN_TOOL_NAMES, BuiltinTool, CallSession, ClawOpsAgent, ControlWebSocket, DECODE_TABLE, DeepSeekLLM, DeepgramSTT, ElevenLabsTTS, FireworksLLM, GeminiLLM, GeminiRealtime, GroqLLM, MCPClient, MediaWebSocket, MistralLLM, OllamaLLM, OpenAICompatLLM, OpenAILLM, OpenAIRealtime, PerplexityLLM, PipelineSession, TogetherLLM, ToolRegistry, XaiLLM, buildControlWsUrl, createAgentLogger, createPipelineLogger, executeBuiltinTool, functionTool, getBuiltinToolSchemas, getTracingConfig, isBuiltinTool, mcpServerHTTP, mcpServerStdio, pcm16ToUlaw, resamplePcm16, resetTracingConfig, setTracingConfig, ulawToPcm16, zodToToolParams };
4252
4258
  //# sourceMappingURL=index.js.map
4253
4259
  //# sourceMappingURL=index.js.map