@framers/agentos 0.1.176 → 0.1.178

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.
Files changed (71) hide show
  1. package/README.md +3 -1
  2. package/dist/api/generateImage.d.ts +6 -0
  3. package/dist/api/generateImage.d.ts.map +1 -1
  4. package/dist/api/generateImage.js +3 -0
  5. package/dist/api/generateImage.js.map +1 -1
  6. package/dist/api/index.d.ts +1 -0
  7. package/dist/api/index.d.ts.map +1 -1
  8. package/dist/api/index.js +1 -0
  9. package/dist/api/index.js.map +1 -1
  10. package/dist/api/transferStyle.d.ts +105 -0
  11. package/dist/api/transferStyle.d.ts.map +1 -0
  12. package/dist/api/transferStyle.js +169 -0
  13. package/dist/api/transferStyle.js.map +1 -0
  14. package/dist/media/avatar/AvatarPipeline.d.ts +5 -1
  15. package/dist/media/avatar/AvatarPipeline.d.ts.map +1 -1
  16. package/dist/media/avatar/AvatarPipeline.js +4 -0
  17. package/dist/media/avatar/AvatarPipeline.js.map +1 -1
  18. package/dist/media/images/IImageProvider.d.ts +58 -0
  19. package/dist/media/images/IImageProvider.d.ts.map +1 -1
  20. package/dist/media/images/IImageProvider.js.map +1 -1
  21. package/dist/media/images/PolicyAwareImageRouter.d.ts +10 -2
  22. package/dist/media/images/PolicyAwareImageRouter.d.ts.map +1 -1
  23. package/dist/media/images/PolicyAwareImageRouter.js +34 -5
  24. package/dist/media/images/PolicyAwareImageRouter.js.map +1 -1
  25. package/dist/media/images/providers/FalImageProvider.d.ts +23 -1
  26. package/dist/media/images/providers/FalImageProvider.d.ts.map +1 -1
  27. package/dist/media/images/providers/FalImageProvider.js +78 -3
  28. package/dist/media/images/providers/FalImageProvider.js.map +1 -1
  29. package/dist/media/images/providers/FluxImageProvider.d.ts.map +1 -1
  30. package/dist/media/images/providers/FluxImageProvider.js +4 -0
  31. package/dist/media/images/providers/FluxImageProvider.js.map +1 -1
  32. package/dist/media/images/providers/OpenAIImageProvider.d.ts.map +1 -1
  33. package/dist/media/images/providers/OpenAIImageProvider.js +4 -0
  34. package/dist/media/images/providers/OpenAIImageProvider.js.map +1 -1
  35. package/dist/media/images/providers/OpenRouterImageProvider.d.ts.map +1 -1
  36. package/dist/media/images/providers/OpenRouterImageProvider.js +4 -0
  37. package/dist/media/images/providers/OpenRouterImageProvider.js.map +1 -1
  38. package/dist/media/images/providers/ReplicateImageProvider.d.ts +14 -0
  39. package/dist/media/images/providers/ReplicateImageProvider.d.ts.map +1 -1
  40. package/dist/media/images/providers/ReplicateImageProvider.js +112 -15
  41. package/dist/media/images/providers/ReplicateImageProvider.js.map +1 -1
  42. package/dist/media/images/providers/StabilityImageProvider.d.ts.map +1 -1
  43. package/dist/media/images/providers/StabilityImageProvider.js +4 -0
  44. package/dist/media/images/providers/StabilityImageProvider.js.map +1 -1
  45. package/dist/media/images/providers/StableDiffusionLocalProvider.d.ts.map +1 -1
  46. package/dist/media/images/providers/StableDiffusionLocalProvider.js +21 -0
  47. package/dist/media/images/providers/StableDiffusionLocalProvider.js.map +1 -1
  48. package/dist/memory/io/facade/Memory.d.ts +7 -6
  49. package/dist/memory/io/facade/Memory.d.ts.map +1 -1
  50. package/dist/memory/io/facade/Memory.js +37 -13
  51. package/dist/memory/io/facade/Memory.js.map +1 -1
  52. package/dist/voice-pipeline/WebSocketStreamTransport.d.ts +8 -8
  53. package/dist/voice-pipeline/WebSocketStreamTransport.js +12 -12
  54. package/dist/voice-pipeline/WebSocketStreamTransport.js.map +1 -1
  55. package/dist/voice-pipeline/index.d.ts +78 -18
  56. package/dist/voice-pipeline/index.d.ts.map +1 -1
  57. package/dist/voice-pipeline/index.js +79 -18
  58. package/dist/voice-pipeline/index.js.map +1 -1
  59. package/dist/voice-pipeline/providers/AgentSessionVoiceAdapter.d.ts +63 -0
  60. package/dist/voice-pipeline/providers/AgentSessionVoiceAdapter.d.ts.map +1 -0
  61. package/dist/voice-pipeline/providers/AgentSessionVoiceAdapter.js +72 -0
  62. package/dist/voice-pipeline/providers/AgentSessionVoiceAdapter.js.map +1 -0
  63. package/dist/voice-pipeline/providers/ElevenLabsStreamingSTT.d.ts +70 -0
  64. package/dist/voice-pipeline/providers/ElevenLabsStreamingSTT.d.ts.map +1 -0
  65. package/dist/voice-pipeline/providers/ElevenLabsStreamingSTT.js +248 -0
  66. package/dist/voice-pipeline/providers/ElevenLabsStreamingSTT.js.map +1 -0
  67. package/dist/voice-pipeline/providers/index.d.ts +13 -0
  68. package/dist/voice-pipeline/providers/index.d.ts.map +1 -0
  69. package/dist/voice-pipeline/providers/index.js +13 -0
  70. package/dist/voice-pipeline/providers/index.js.map +1 -0
  71. package/package.json +1 -1
@@ -0,0 +1,72 @@
1
+ /**
2
+ * @module voice-pipeline/providers/AgentSessionVoiceAdapter
3
+ *
4
+ * Adapts an AgentOS {@link AgentSession} to the {@link IVoicePipelineAgentSession}
5
+ * interface required by {@link VoicePipelineOrchestrator}.
6
+ *
7
+ * The adapter wraps `AgentSession.stream(text)` and yields the resulting
8
+ * `textStream` (an `AsyncIterable<string>` of token deltas) as the return
9
+ * value of `sendText()`.
10
+ *
11
+ * ## Abort Handling
12
+ *
13
+ * The `abort()` method is implemented by setting an internal flag that causes
14
+ * the `sendText()` iterator to stop yielding tokens. Since `StreamTextResult`
15
+ * does not expose a native cancellation mechanism, the underlying provider
16
+ * stream continues but its output is discarded.
17
+ */
18
+ /**
19
+ * Wraps an AgentOS `AgentSession` as an `IVoicePipelineAgentSession`.
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * import { agent } from '@framers/agentos';
24
+ * import { AgentSessionVoiceAdapter } from '../../voice-pipeline/index.js';
25
+ *
26
+ * const a = agent({ model: 'gpt-4o' });
27
+ * const session = a.session('voice-session-1');
28
+ * const voiceAdapter = new AgentSessionVoiceAdapter(session);
29
+ *
30
+ * // Use with VoicePipelineOrchestrator
31
+ * orchestrator.startSession(transport, voiceAdapter, overrides);
32
+ * ```
33
+ */
34
+ export class AgentSessionVoiceAdapter {
35
+ constructor(session) {
36
+ this.session = session;
37
+ /** Internal abort flag. Set by `abort()`, checked by the token iterator. */
38
+ this.aborted = false;
39
+ }
40
+ /**
41
+ * Send user text to the agent and yield response tokens as an async iterable.
42
+ *
43
+ * The `metadata` parameter carries voice-specific context (speech duration,
44
+ * endpoint reason, confidence, etc.) that could be injected into the agent's
45
+ * context for more informed responses. Currently the metadata is not forwarded
46
+ * to the agent (the AgentSession API doesn't support metadata injection),
47
+ * but it is available for future enhancement.
48
+ *
49
+ * @param text - Transcribed user speech to send to the agent.
50
+ * @param _metadata - Voice turn metadata (reserved for future use).
51
+ * @returns An async iterable of response token strings.
52
+ */
53
+ async *sendText(text, _metadata) {
54
+ this.aborted = false;
55
+ const result = this.session.stream(text);
56
+ for await (const token of result.textStream) {
57
+ if (this.aborted)
58
+ break;
59
+ yield token;
60
+ }
61
+ }
62
+ /**
63
+ * Abort the current generation.
64
+ * Sets an internal flag causing the active `sendText()` iterator to stop
65
+ * yielding tokens. The underlying LLM stream is not explicitly cancelled
66
+ * but its output is discarded.
67
+ */
68
+ abort() {
69
+ this.aborted = true;
70
+ }
71
+ }
72
+ //# sourceMappingURL=AgentSessionVoiceAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentSessionVoiceAdapter.js","sourceRoot":"","sources":["../../../src/voice-pipeline/providers/AgentSessionVoiceAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,wBAAwB;IAInC,YAA6B,OAAqB;QAArB,YAAO,GAAP,OAAO,CAAc;QAHlD,4EAA4E;QACpE,YAAO,GAAG,KAAK,CAAC;IAE6B,CAAC;IAEtD;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAY,EAAE,SAA4B;QACxD,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QAErB,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAEzC,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YAC5C,IAAI,IAAI,CAAC,OAAO;gBAAE,MAAM;YACxB,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,KAAK;QACH,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;IACtB,CAAC;CACF"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * @module voice-pipeline/providers/ElevenLabsStreamingSTT
3
+ *
4
+ * Streaming speech-to-text adapter for ElevenLabs' WebSocket STT API.
5
+ * Implements {@link IStreamingSTT} / {@link StreamingSTTSession} for the
6
+ * voice pipeline orchestrator.
7
+ *
8
+ * ## ElevenLabs STT WebSocket Protocol
9
+ *
10
+ * - **Endpoint:** `wss://api.elevenlabs.io/v1/speech-to-text/stream`
11
+ * - **Authentication:** `xi-api-key` header on upgrade
12
+ * - **Inbound (client → ElevenLabs):** Binary PCM frames (16-bit signed LE, 16kHz mono)
13
+ * - **Outbound (ElevenLabs → client):** JSON transcript results
14
+ * - **Close:** Send JSON `{ "type": "close_stream" }` to finalize
15
+ *
16
+ * ## Fallback: Chunked REST
17
+ *
18
+ * If the WebSocket endpoint is unavailable or errors, this adapter falls back
19
+ * to a chunked REST approach: accumulates audio into ~2s chunks and POSTs each
20
+ * to `/v1/speech-to-text` for batch transcription. This provides near-realtime
21
+ * results (2s latency per chunk) using only the REST API.
22
+ *
23
+ * @see https://elevenlabs.io/docs/api-reference/speech-to-text
24
+ */
25
+ import type { IStreamingSTT, StreamingSTTSession, StreamingSTTConfig } from '../types.js';
26
+ /**
27
+ * Configuration for the {@link ElevenLabsStreamingSTT} provider.
28
+ */
29
+ export interface ElevenLabsStreamingSTTConfig {
30
+ /** ElevenLabs API key. */
31
+ apiKey: string;
32
+ /**
33
+ * Base URL for the ElevenLabs API.
34
+ * @default 'https://api.elevenlabs.io/v1'
35
+ */
36
+ baseUrl?: string;
37
+ /**
38
+ * STT model to use.
39
+ * @default 'scribe_v1'
40
+ */
41
+ model?: string;
42
+ }
43
+ /**
44
+ * Streaming STT provider using ElevenLabs' Speech-to-Text API.
45
+ *
46
+ * Uses chunked REST transcription (2-second audio windows) to provide
47
+ * near-realtime STT with the same ElevenLabs API key used for TTS.
48
+ * No separate Deepgram key required.
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * const stt = new ElevenLabsStreamingSTT({
53
+ * apiKey: process.env.ELEVENLABS_API_KEY!,
54
+ * });
55
+ * const session = await stt.startSession({ language: 'en' });
56
+ * session.on('transcript', (event) => console.log(event.text));
57
+ * ```
58
+ */
59
+ export declare class ElevenLabsStreamingSTT implements IStreamingSTT {
60
+ private readonly config;
61
+ readonly providerId = "elevenlabs-streaming-stt";
62
+ readonly isStreaming = true;
63
+ constructor(config: ElevenLabsStreamingSTTConfig);
64
+ /**
65
+ * Create a new STT session. Uses chunked REST calls to ElevenLabs'
66
+ * batch STT endpoint for near-realtime transcription.
67
+ */
68
+ startSession(config?: StreamingSTTConfig): Promise<StreamingSTTSession>;
69
+ }
70
+ //# sourceMappingURL=ElevenLabsStreamingSTT.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ElevenLabsStreamingSTT.d.ts","sourceRoot":"","sources":["../../../src/voice-pipeline/providers/ElevenLabsStreamingSTT.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAInB,MAAM,aAAa,CAAC;AAMrB;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAoQD;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,sBAAuB,YAAW,aAAa;IAI9C,OAAO,CAAC,QAAQ,CAAC,MAAM;IAHnC,QAAQ,CAAC,UAAU,8BAA8B;IACjD,QAAQ,CAAC,WAAW,QAAQ;gBAEC,MAAM,EAAE,4BAA4B;IAEjE;;;OAGG;IACG,YAAY,CAAC,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAG9E"}
@@ -0,0 +1,248 @@
1
+ /**
2
+ * @module voice-pipeline/providers/ElevenLabsStreamingSTT
3
+ *
4
+ * Streaming speech-to-text adapter for ElevenLabs' WebSocket STT API.
5
+ * Implements {@link IStreamingSTT} / {@link StreamingSTTSession} for the
6
+ * voice pipeline orchestrator.
7
+ *
8
+ * ## ElevenLabs STT WebSocket Protocol
9
+ *
10
+ * - **Endpoint:** `wss://api.elevenlabs.io/v1/speech-to-text/stream`
11
+ * - **Authentication:** `xi-api-key` header on upgrade
12
+ * - **Inbound (client → ElevenLabs):** Binary PCM frames (16-bit signed LE, 16kHz mono)
13
+ * - **Outbound (ElevenLabs → client):** JSON transcript results
14
+ * - **Close:** Send JSON `{ "type": "close_stream" }` to finalize
15
+ *
16
+ * ## Fallback: Chunked REST
17
+ *
18
+ * If the WebSocket endpoint is unavailable or errors, this adapter falls back
19
+ * to a chunked REST approach: accumulates audio into ~2s chunks and POSTs each
20
+ * to `/v1/speech-to-text` for batch transcription. This provides near-realtime
21
+ * results (2s latency per chunk) using only the REST API.
22
+ *
23
+ * @see https://elevenlabs.io/docs/api-reference/speech-to-text
24
+ */
25
+ import { EventEmitter } from 'node:events';
26
+ // ---------------------------------------------------------------------------
27
+ // Session Implementation — Chunked REST fallback
28
+ // ---------------------------------------------------------------------------
29
+ /**
30
+ * ElevenLabs streaming STT session using chunked REST calls.
31
+ *
32
+ * Accumulates PCM audio into ~2-second chunks and sends each to the
33
+ * ElevenLabs batch STT endpoint. Provides near-realtime transcription
34
+ * with the same API key used for TTS.
35
+ */
36
+ class ElevenLabsChunkedSTTSession extends EventEmitter {
37
+ constructor(config, sessionConfig) {
38
+ super();
39
+ this.config = config;
40
+ this.sessionConfig = sessionConfig;
41
+ this.closed = false;
42
+ this.speechActive = false;
43
+ this.audioBuffer = [];
44
+ this.bufferSamples = 0;
45
+ this.flushTimer = null;
46
+ // Flush accumulated audio every 2 seconds
47
+ this.flushTimer = setInterval(() => {
48
+ if (this.bufferSamples > 0) {
49
+ this._transcribeBuffer();
50
+ }
51
+ }, 2000);
52
+ }
53
+ /**
54
+ * Push a PCM audio frame. Converts Float32 to Int16 and accumulates.
55
+ */
56
+ pushAudio(frame) {
57
+ if (this.closed)
58
+ return;
59
+ // Convert Float32 [-1, 1] to Int16 PCM
60
+ const pcm = new Int16Array(frame.samples.length);
61
+ for (let i = 0; i < frame.samples.length; i++) {
62
+ const s = Math.max(-1, Math.min(1, frame.samples[i]));
63
+ pcm[i] = s < 0 ? s * 0x8000 : s * 0x7fff;
64
+ }
65
+ this.audioBuffer.push(pcm);
66
+ this.bufferSamples += pcm.length;
67
+ // Detect speech activity from energy
68
+ let energy = 0;
69
+ for (let i = 0; i < pcm.length; i++) {
70
+ energy += Math.abs(pcm[i]);
71
+ }
72
+ energy /= pcm.length;
73
+ if (energy > 500 && !this.speechActive) {
74
+ this.speechActive = true;
75
+ this.emit('speech_start');
76
+ }
77
+ }
78
+ /**
79
+ * Flush any remaining audio and transcribe.
80
+ */
81
+ async flush() {
82
+ if (this.bufferSamples > 0) {
83
+ await this._transcribeBuffer();
84
+ }
85
+ }
86
+ /**
87
+ * Close the session and stop the flush timer.
88
+ */
89
+ close() {
90
+ if (this.closed)
91
+ return;
92
+ this.closed = true;
93
+ if (this.flushTimer) {
94
+ clearInterval(this.flushTimer);
95
+ this.flushTimer = null;
96
+ }
97
+ this.emit('close');
98
+ }
99
+ // -------------------------------------------------------------------------
100
+ // Private
101
+ // -------------------------------------------------------------------------
102
+ /**
103
+ * Concatenate accumulated PCM chunks into a WAV buffer and POST to
104
+ * ElevenLabs batch STT endpoint.
105
+ */
106
+ async _transcribeBuffer() {
107
+ // Concatenate all accumulated Int16 chunks
108
+ const totalSamples = this.bufferSamples;
109
+ const combined = new Int16Array(totalSamples);
110
+ let offset = 0;
111
+ for (const chunk of this.audioBuffer) {
112
+ combined.set(chunk, offset);
113
+ offset += chunk.length;
114
+ }
115
+ // Clear the buffer
116
+ this.audioBuffer = [];
117
+ this.bufferSamples = 0;
118
+ // Build a minimal WAV file
119
+ const wavBuffer = this._buildWav(combined, 16000);
120
+ try {
121
+ const baseUrl = this.config.baseUrl ?? 'https://api.elevenlabs.io/v1';
122
+ // Create form data with the WAV audio
123
+ const boundary = '----ElevenLabsSTTBoundary' + Date.now();
124
+ const languageCode = this.sessionConfig.language ?? 'en';
125
+ // Build multipart body manually (Node.js Buffer-based)
126
+ const parts = [];
127
+ parts.push(Buffer.from(`--${boundary}\r\n`));
128
+ parts.push(Buffer.from(`Content-Disposition: form-data; name="audio"; filename="audio.wav"\r\nContent-Type: audio/wav\r\n\r\n`));
129
+ parts.push(Buffer.from(wavBuffer));
130
+ parts.push(Buffer.from(`\r\n--${boundary}\r\n`));
131
+ parts.push(Buffer.from(`Content-Disposition: form-data; name="language_code"\r\n\r\n${languageCode}\r\n`));
132
+ if (this.config.model) {
133
+ parts.push(Buffer.from(`--${boundary}\r\n`));
134
+ parts.push(Buffer.from(`Content-Disposition: form-data; name="model_id"\r\n\r\n${this.config.model}\r\n`));
135
+ }
136
+ parts.push(Buffer.from(`--${boundary}--\r\n`));
137
+ const body = Buffer.concat(parts);
138
+ const response = await fetch(`${baseUrl}/speech-to-text`, {
139
+ method: 'POST',
140
+ headers: {
141
+ 'xi-api-key': this.config.apiKey,
142
+ 'Content-Type': `multipart/form-data; boundary=${boundary}`,
143
+ },
144
+ body,
145
+ });
146
+ if (!response.ok) {
147
+ const errText = await response.text();
148
+ this.emit('error', new Error(`ElevenLabs STT failed (${response.status}): ${errText}`));
149
+ return;
150
+ }
151
+ const data = (await response.json());
152
+ if (data.text) {
153
+ const words = (data.words ?? []).map((w) => ({
154
+ word: w.text,
155
+ start: Math.round(w.start * 1000),
156
+ end: Math.round(w.end * 1000),
157
+ confidence: w.confidence ?? 0.9,
158
+ }));
159
+ const event = {
160
+ text: data.text,
161
+ confidence: words.length > 0 ? words.reduce((s, w) => s + w.confidence, 0) / words.length : 0.9,
162
+ words,
163
+ isFinal: true,
164
+ durationMs: Math.round((totalSamples / 16000) * 1000),
165
+ };
166
+ this.emit('transcript', event);
167
+ // Emit speech_end after a final transcript
168
+ if (this.speechActive) {
169
+ this.speechActive = false;
170
+ this.emit('speech_end');
171
+ }
172
+ }
173
+ }
174
+ catch (err) {
175
+ this.emit('error', err instanceof Error ? err : new Error(String(err)));
176
+ }
177
+ }
178
+ /**
179
+ * Build a minimal WAV file header + PCM data.
180
+ */
181
+ _buildWav(pcm, sampleRate) {
182
+ const dataSize = pcm.length * 2; // 16-bit = 2 bytes per sample
183
+ const buffer = new ArrayBuffer(44 + dataSize);
184
+ const view = new DataView(buffer);
185
+ // RIFF header
186
+ this._writeString(view, 0, 'RIFF');
187
+ view.setUint32(4, 36 + dataSize, true);
188
+ this._writeString(view, 8, 'WAVE');
189
+ // fmt chunk
190
+ this._writeString(view, 12, 'fmt ');
191
+ view.setUint32(16, 16, true); // chunk size
192
+ view.setUint16(20, 1, true); // PCM format
193
+ view.setUint16(22, 1, true); // mono
194
+ view.setUint32(24, sampleRate, true);
195
+ view.setUint32(28, sampleRate * 2, true); // byte rate
196
+ view.setUint16(32, 2, true); // block align
197
+ view.setUint16(34, 16, true); // bits per sample
198
+ // data chunk
199
+ this._writeString(view, 36, 'data');
200
+ view.setUint32(40, dataSize, true);
201
+ // PCM data
202
+ const output = new Int16Array(buffer, 44);
203
+ output.set(pcm);
204
+ return buffer;
205
+ }
206
+ /** Write an ASCII string into a DataView at the given offset. */
207
+ _writeString(view, offset, str) {
208
+ for (let i = 0; i < str.length; i++) {
209
+ view.setUint8(offset + i, str.charCodeAt(i));
210
+ }
211
+ }
212
+ }
213
+ /** Samples per chunk: 2 seconds at 16kHz = 32,000 samples. */
214
+ ElevenLabsChunkedSTTSession.CHUNK_SAMPLES = 32000;
215
+ // ---------------------------------------------------------------------------
216
+ // Provider (Factory)
217
+ // ---------------------------------------------------------------------------
218
+ /**
219
+ * Streaming STT provider using ElevenLabs' Speech-to-Text API.
220
+ *
221
+ * Uses chunked REST transcription (2-second audio windows) to provide
222
+ * near-realtime STT with the same ElevenLabs API key used for TTS.
223
+ * No separate Deepgram key required.
224
+ *
225
+ * @example
226
+ * ```typescript
227
+ * const stt = new ElevenLabsStreamingSTT({
228
+ * apiKey: process.env.ELEVENLABS_API_KEY!,
229
+ * });
230
+ * const session = await stt.startSession({ language: 'en' });
231
+ * session.on('transcript', (event) => console.log(event.text));
232
+ * ```
233
+ */
234
+ export class ElevenLabsStreamingSTT {
235
+ constructor(config) {
236
+ this.config = config;
237
+ this.providerId = 'elevenlabs-streaming-stt';
238
+ this.isStreaming = true;
239
+ }
240
+ /**
241
+ * Create a new STT session. Uses chunked REST calls to ElevenLabs'
242
+ * batch STT endpoint for near-realtime transcription.
243
+ */
244
+ async startSession(config) {
245
+ return new ElevenLabsChunkedSTTSession(this.config, config ?? {});
246
+ }
247
+ }
248
+ //# sourceMappingURL=ElevenLabsStreamingSTT.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ElevenLabsStreamingSTT.js","sourceRoot":"","sources":["../../../src/voice-pipeline/providers/ElevenLabsStreamingSTT.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAsD3C,8EAA8E;AAC9E,iDAAiD;AACjD,8EAA8E;AAE9E;;;;;;GAMG;AACH,MAAM,2BAA4B,SAAQ,YAAY;IAUpD,YACmB,MAAoC,EACpC,aAAiC;QAElD,KAAK,EAAE,CAAC;QAHS,WAAM,GAAN,MAAM,CAA8B;QACpC,kBAAa,GAAb,aAAa,CAAoB;QAX5C,WAAM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ACpC,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;;AAtND,8DAA8D;AACtC,yCAAa,GAAG,KAAM,AAAT,CAAU;AAwNjD,8EAA8E;AAC9E,qBAAqB;AACrB,8EAA8E;AAE9E;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,sBAAsB;IAIjC,YAA6B,MAAoC;QAApC,WAAM,GAAN,MAAM,CAA8B;QAHxD,eAAU,GAAG,0BAA0B,CAAC;QACxC,gBAAW,GAAG,IAAI,CAAC;IAEwC,CAAC;IAErE;;;OAGG;IACH,KAAK,CAAC,YAAY,CAAC,MAA2B;QAC5C,OAAO,IAAI,2BAA2B,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,IAAI,EAAE,CAAC,CAAC;IACpE,CAAC;CACF"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @module voice-pipeline/providers
3
+ *
4
+ * Concrete provider implementations for the voice pipeline:
5
+ * - {@link DeepgramStreamingSTT} — Deepgram WebSocket streaming STT
6
+ * - {@link ElevenLabsStreamingTTS} — ElevenLabs WebSocket streaming TTS
7
+ * - {@link AgentSessionVoiceAdapter} — AgentOS session → voice pipeline adapter
8
+ */
9
+ export { DeepgramStreamingSTT, type DeepgramStreamingSTTConfig } from './DeepgramStreamingSTT.js';
10
+ export { ElevenLabsStreamingSTT, type ElevenLabsStreamingSTTConfig, } from './ElevenLabsStreamingSTT.js';
11
+ export { ElevenLabsStreamingTTS, type ElevenLabsStreamingTTSConfig, } from './ElevenLabsStreamingTTS.js';
12
+ export { AgentSessionVoiceAdapter } from './AgentSessionVoiceAdapter.js';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/voice-pipeline/providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,oBAAoB,EAAE,KAAK,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAClG,OAAO,EACL,sBAAsB,EACtB,KAAK,4BAA4B,GAClC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,sBAAsB,EACtB,KAAK,4BAA4B,GAClC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @module voice-pipeline/providers
3
+ *
4
+ * Concrete provider implementations for the voice pipeline:
5
+ * - {@link DeepgramStreamingSTT} — Deepgram WebSocket streaming STT
6
+ * - {@link ElevenLabsStreamingTTS} — ElevenLabs WebSocket streaming TTS
7
+ * - {@link AgentSessionVoiceAdapter} — AgentOS session → voice pipeline adapter
8
+ */
9
+ export { DeepgramStreamingSTT } from './DeepgramStreamingSTT.js';
10
+ export { ElevenLabsStreamingSTT, } from './ElevenLabsStreamingSTT.js';
11
+ export { ElevenLabsStreamingTTS, } from './ElevenLabsStreamingTTS.js';
12
+ export { AgentSessionVoiceAdapter } from './AgentSessionVoiceAdapter.js';
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/voice-pipeline/providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,oBAAoB,EAAmC,MAAM,2BAA2B,CAAC;AAClG,OAAO,EACL,sBAAsB,GAEvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,sBAAsB,GAEvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@framers/agentos",
3
- "version": "0.1.176",
3
+ "version": "0.1.178",
4
4
  "description": "Modular AgentOS orchestration library",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",