Refactor VoiceAgent: Extract types and default configurations into separate types.ts file; remove unused StreamBuffer file

This commit is contained in:
Bijit Mondal
2026-02-19 16:01:25 +05:30
parent ce10d521f3
commit ac505c4ed9
23 changed files with 3570 additions and 82 deletions

13
dist/VoiceAgent.js vendored
View File

@@ -4,8 +4,7 @@ exports.VoiceAgent = void 0;
const ws_1 = require("ws");
const events_1 = require("events");
const ai_1 = require("ai");
/** Default maximum audio input size (10 MB) */
const DEFAULT_MAX_AUDIO_SIZE = 10 * 1024 * 1024;
const types_1 = require("./types");
class VoiceAgent extends events_1.EventEmitter {
socket;
tools = {};
@@ -52,22 +51,18 @@ class VoiceAgent extends events_1.EventEmitter {
this.voice = options.voice || "alloy";
this.speechInstructions = options.speechInstructions;
this.outputFormat = options.outputFormat || "mp3";
this.maxAudioInputSize = options.maxAudioInputSize ?? DEFAULT_MAX_AUDIO_SIZE;
this.maxAudioInputSize = options.maxAudioInputSize ?? types_1.DEFAULT_MAX_AUDIO_SIZE;
if (options.tools) {
this.tools = { ...options.tools };
}
// Initialize streaming speech config with defaults
this.streamingSpeechConfig = {
minChunkSize: 50,
maxChunkSize: 200,
parallelGeneration: true,
maxParallelRequests: 3,
...types_1.DEFAULT_STREAMING_SPEECH_CONFIG,
...options.streamingSpeech,
};
// Initialize history config with defaults
this.historyConfig = {
maxMessages: 100,
maxTotalChars: 0, // unlimited by default
...types_1.DEFAULT_HISTORY_CONFIG,
...options.history,
};
}