mirror of
https://github.com/Bijit-Mondal/VoiceAgent.git
synced 2026-03-02 10:36:37 +00:00
- Added ConversationManager for managing conversation history with configurable limits. - Implemented InputQueue for serial processing of input items. - Created SpeechManager for handling text-to-speech generation and streaming. - Developed StreamProcessor for processing LLM streams and forwarding events. - Added TranscriptionManager for audio transcription using AI SDK. - Introduced WebSocketManager for managing WebSocket connections and messaging. - Updated VoiceAgent to support new architecture and improved socket handling. - Refactored index files to export new core components.
61 lines
1.6 KiB
JavaScript
61 lines
1.6 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.InputQueue = void 0;
|
|
class InputQueue {
|
|
queue = [];
|
|
processing = false;
|
|
/** Callback invoked for each item — must return a resolved value */
|
|
processor = async () => "";
|
|
/**
|
|
* Enqueue an item for serial processing.
|
|
*/
|
|
enqueue(item) {
|
|
this.queue.push(item);
|
|
this.drain();
|
|
}
|
|
/**
|
|
* Reject all pending items (used on disconnect/destroy).
|
|
*/
|
|
rejectAll(reason) {
|
|
for (const item of this.queue) {
|
|
item.reject(reason);
|
|
}
|
|
this.queue = [];
|
|
this.processing = false;
|
|
}
|
|
/**
|
|
* Number of items waiting in the queue.
|
|
*/
|
|
get length() {
|
|
return this.queue.length;
|
|
}
|
|
/**
|
|
* Whether the queue is currently processing an item.
|
|
*/
|
|
get isProcessing() {
|
|
return this.processing;
|
|
}
|
|
// ── Private ──────────────────────────────────────────
|
|
async drain() {
|
|
if (this.processing)
|
|
return;
|
|
this.processing = true;
|
|
try {
|
|
while (this.queue.length > 0) {
|
|
const item = this.queue.shift();
|
|
try {
|
|
const result = await this.processor(item);
|
|
item.resolve(result);
|
|
}
|
|
catch (error) {
|
|
item.reject(error);
|
|
}
|
|
}
|
|
}
|
|
finally {
|
|
this.processing = false;
|
|
}
|
|
}
|
|
}
|
|
exports.InputQueue = InputQueue;
|
|
//# sourceMappingURL=InputQueue.js.map
|