@framers/agentos 0.1.168 → 0.1.169
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.
- package/dist/orchestration/runtime/VoiceTransportAdapter.d.ts +24 -86
- package/dist/orchestration/runtime/VoiceTransportAdapter.d.ts.map +1 -1
- package/dist/orchestration/runtime/VoiceTransportAdapter.js +66 -84
- package/dist/orchestration/runtime/VoiceTransportAdapter.js.map +1 -1
- package/package.json +1 -1
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
*
|
|
14
14
|
* ## `getNodeInput` / `deliverNodeOutput` contract
|
|
15
15
|
*
|
|
16
|
-
* - `getNodeInput(nodeId)`
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* - `deliverNodeOutput(nodeId, output)`
|
|
20
|
-
*
|
|
16
|
+
* - `getNodeInput(nodeId)` delegates to `pipeline.waitForUserTurn()` when a
|
|
17
|
+
* pipeline is available, or falls back to listening for `turn_complete` on
|
|
18
|
+
* the transport directly.
|
|
19
|
+
* - `deliverNodeOutput(nodeId, output)` delegates to `pipeline.pushToTTS()`
|
|
20
|
+
* and emits a `voice_audio` outbound GraphEvent.
|
|
21
21
|
* - Both methods throw if called before `init()`.
|
|
22
22
|
*
|
|
23
23
|
* ## Lazy initialisation
|
|
@@ -51,19 +51,6 @@ import type { GraphEvent } from '../events/GraphEvent.js';
|
|
|
51
51
|
*
|
|
52
52
|
* All fields are optional -- defaults are resolved from agent.config.json or
|
|
53
53
|
* sensible library defaults within the voice pipeline itself.
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* ```ts
|
|
57
|
-
* const config: VoiceTransportConfig = {
|
|
58
|
-
* stt: 'deepgram',
|
|
59
|
-
* tts: 'elevenlabs',
|
|
60
|
-
* voice: 'rachel',
|
|
61
|
-
* bargeIn: 'hard-cut',
|
|
62
|
-
* endpointing: 'semantic',
|
|
63
|
-
* diarization: true,
|
|
64
|
-
* language: 'en-US',
|
|
65
|
-
* };
|
|
66
|
-
* ```
|
|
67
54
|
*/
|
|
68
55
|
export interface VoiceTransportConfig {
|
|
69
56
|
/** STT provider identifier (e.g. `'deepgram'`, `'openai'`). */
|
|
@@ -98,22 +85,14 @@ export interface VoiceTransportConfig {
|
|
|
98
85
|
*
|
|
99
86
|
* 1. Construct with {@link VoiceTransportConfig}, an `IStreamTransport`, and an
|
|
100
87
|
* event sink callback.
|
|
101
|
-
* 2. Call `init()` once before the graph starts running. This
|
|
102
|
-
*
|
|
103
|
-
*
|
|
88
|
+
* 2. Call `init()` once before the graph starts running. This lazily imports
|
|
89
|
+
* `VoicePipelineOrchestrator`, creates an instance, and injects the transport
|
|
90
|
+
* into `state.scratch.voiceTransport`.
|
|
104
91
|
* 3. Use `getNodeInput()` to obtain the user's transcribed speech for a node.
|
|
105
|
-
*
|
|
106
|
-
* 4. Use `deliverNodeOutput()` to send the node's response to TTS
|
|
92
|
+
* Delegates to `pipeline.waitForUserTurn()` when a pipeline is available.
|
|
93
|
+
* 4. Use `deliverNodeOutput()` to send the node's response to TTS via
|
|
94
|
+
* `pipeline.pushToTTS()`.
|
|
107
95
|
* 5. Call `dispose()` to clean up resources when the session ends.
|
|
108
|
-
*
|
|
109
|
-
* ## Error handling
|
|
110
|
-
*
|
|
111
|
-
* Both `getNodeInput()` and `deliverNodeOutput()` throw `Error` if called
|
|
112
|
-
* before `init()`. After `dispose()`, the adapter is marked as uninitialised
|
|
113
|
-
* so subsequent calls also throw.
|
|
114
|
-
*
|
|
115
|
-
* @see {@link VoiceTransportConfig} -- the config shape forwarded to the pipeline.
|
|
116
|
-
* See `VoiceNodeExecutor` for the executor that interacts with the transport.
|
|
117
96
|
*/
|
|
118
97
|
export declare class VoiceTransportAdapter {
|
|
119
98
|
private readonly config;
|
|
@@ -122,7 +101,6 @@ export declare class VoiceTransportAdapter {
|
|
|
122
101
|
/**
|
|
123
102
|
* Lazily-initialised `VoicePipelineOrchestrator` instance.
|
|
124
103
|
* Typed as `any` to avoid a hard import cycle with the voice subsystem.
|
|
125
|
-
* In a full implementation this would be `VoicePipelineOrchestrator | null`.
|
|
126
104
|
*/
|
|
127
105
|
private pipeline;
|
|
128
106
|
/**
|
|
@@ -133,11 +111,8 @@ export declare class VoiceTransportAdapter {
|
|
|
133
111
|
/**
|
|
134
112
|
* Creates a new VoiceTransportAdapter.
|
|
135
113
|
*
|
|
136
|
-
* @param config - Voice pipeline configuration knobs.
|
|
137
|
-
*
|
|
138
|
-
* @param transport - Bidirectional audio/control stream transport
|
|
139
|
-
* (`IStreamTransport`). Must be an EventEmitter that
|
|
140
|
-
* emits `turn_complete` events for `getNodeInput()`.
|
|
114
|
+
* @param config - Voice pipeline configuration knobs.
|
|
115
|
+
* @param transport - Bidirectional audio/control stream transport (`IStreamTransport`).
|
|
141
116
|
* @param eventSink - Callback receiving all `GraphEvent` values emitted by
|
|
142
117
|
* this adapter. Must not throw.
|
|
143
118
|
*/
|
|
@@ -146,73 +121,36 @@ export declare class VoiceTransportAdapter {
|
|
|
146
121
|
/**
|
|
147
122
|
* Initialise the adapter.
|
|
148
123
|
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
* started event to signal that the voice session is live.
|
|
153
|
-
*
|
|
154
|
-
* Must be called exactly once before `getNodeInput()` or
|
|
155
|
-
* `deliverNodeOutput()`. Calling `init()` multiple times is safe but
|
|
156
|
-
* redundant -- the transport reference is simply overwritten.
|
|
157
|
-
*
|
|
158
|
-
* @param state - Mutable `GraphState` (or partial) for the current run.
|
|
159
|
-
* `state.scratch` is created lazily if absent.
|
|
124
|
+
* Lazily imports `VoicePipelineOrchestrator`, creates an instance from config,
|
|
125
|
+
* injects the transport into `state.scratch.voiceTransport`, and emits a
|
|
126
|
+
* `voice_session` started event.
|
|
160
127
|
*/
|
|
161
128
|
init(state: Partial<GraphState>): Promise<void>;
|
|
162
129
|
/**
|
|
163
130
|
* Wait for the user's next speech turn and return the transcript text.
|
|
164
131
|
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
* it listens for a single `'turn_complete'` event from the underlying transport
|
|
168
|
-
* and resolves with the transcript text.
|
|
169
|
-
*
|
|
170
|
-
* Also emits a {@link GraphEvent} of type `voice_turn_complete` so that the
|
|
171
|
-
* runtime event bus stays in sync with the transport-level turn lifecycle.
|
|
172
|
-
*
|
|
173
|
-
* @param nodeId - The id of the graph node requesting input; used to tag the
|
|
174
|
-
* emitted event for downstream filtering.
|
|
175
|
-
* @returns Resolved transcript string from the user's speech turn.
|
|
176
|
-
* @throws {Error} If called before `init()` or after `dispose()`.
|
|
132
|
+
* Delegates to `VoicePipelineOrchestrator.waitForUserTurn()` when a pipeline
|
|
133
|
+
* is available. Falls back to listening for `turn_complete` on the transport.
|
|
177
134
|
*/
|
|
178
135
|
getNodeInput(nodeId: string): Promise<string>;
|
|
179
136
|
/**
|
|
180
137
|
* Deliver a node's text output to the TTS engine.
|
|
181
138
|
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
* this delegates to `VoicePipelineOrchestrator.pushToTTS(output)`.
|
|
185
|
-
*
|
|
186
|
-
* Emits a {@link GraphEvent} of type `voice_audio` (direction `'outbound'`)
|
|
187
|
-
* so that the runtime event bus records the TTS delivery.
|
|
188
|
-
*
|
|
189
|
-
* @param nodeId - The id of the graph node delivering the output; tags the
|
|
190
|
-
* emitted event for downstream filtering.
|
|
191
|
-
* @param _output - Text or async token stream to synthesise as speech.
|
|
192
|
-
* The underscore prefix indicates it is not yet consumed
|
|
193
|
-
* in the v1 stub implementation.
|
|
194
|
-
* @throws {Error} If called before `init()` or after `dispose()`.
|
|
139
|
+
* Delegates to `VoicePipelineOrchestrator.pushToTTS()` when a pipeline is
|
|
140
|
+
* available, then emits a `voice_audio` outbound GraphEvent.
|
|
195
141
|
*/
|
|
196
|
-
deliverNodeOutput(nodeId: string,
|
|
142
|
+
deliverNodeOutput(nodeId: string, output: string | AsyncIterable<string>): Promise<void>;
|
|
197
143
|
/**
|
|
198
144
|
* Handle a user barge-in at the transport level.
|
|
199
145
|
*
|
|
200
|
-
*
|
|
201
|
-
* speaking while the agent is mid-utterance. Emits a `voice_barge_in` event
|
|
202
|
-
* so that graph event consumers can react (e.g. cancel pending tool calls,
|
|
203
|
-
* stop TTS playback, or reroute the graph).
|
|
204
|
-
*
|
|
205
|
-
* @see {@link VoiceInterruptError} -- the structured error used inside the graph executor.
|
|
146
|
+
* Emits a `voice_barge_in` event so that graph event consumers can react.
|
|
206
147
|
*/
|
|
207
148
|
handleBargeIn(): void;
|
|
208
149
|
/**
|
|
209
150
|
* Dispose the adapter and emit a `voice_session` ended event.
|
|
210
151
|
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
* This method is idempotent -- calling it multiple times simply re-emits the
|
|
215
|
-
* ended event and re-sets the initialised flag.
|
|
152
|
+
* Stops the pipeline if one was initialised, then marks the adapter as
|
|
153
|
+
* uninitialised so subsequent calls throw.
|
|
216
154
|
*/
|
|
217
155
|
dispose(): Promise<void>;
|
|
218
156
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoiceTransportAdapter.d.ts","sourceRoot":"","sources":["../../../src/orchestration/runtime/VoiceTransportAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAM1D
|
|
1
|
+
{"version":3,"file":"VoiceTransportAdapter.d.ts","sourceRoot":"","sources":["../../../src/orchestration/runtime/VoiceTransportAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU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OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAc/B"}
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
*
|
|
14
14
|
* ## `getNodeInput` / `deliverNodeOutput` contract
|
|
15
15
|
*
|
|
16
|
-
* - `getNodeInput(nodeId)`
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* - `deliverNodeOutput(nodeId, output)`
|
|
20
|
-
*
|
|
16
|
+
* - `getNodeInput(nodeId)` delegates to `pipeline.waitForUserTurn()` when a
|
|
17
|
+
* pipeline is available, or falls back to listening for `turn_complete` on
|
|
18
|
+
* the transport directly.
|
|
19
|
+
* - `deliverNodeOutput(nodeId, output)` delegates to `pipeline.pushToTTS()`
|
|
20
|
+
* and emits a `voice_audio` outbound GraphEvent.
|
|
21
21
|
* - Both methods throw if called before `init()`.
|
|
22
22
|
*
|
|
23
23
|
* ## Lazy initialisation
|
|
@@ -53,32 +53,21 @@
|
|
|
53
53
|
*
|
|
54
54
|
* 1. Construct with {@link VoiceTransportConfig}, an `IStreamTransport`, and an
|
|
55
55
|
* event sink callback.
|
|
56
|
-
* 2. Call `init()` once before the graph starts running. This
|
|
57
|
-
*
|
|
58
|
-
*
|
|
56
|
+
* 2. Call `init()` once before the graph starts running. This lazily imports
|
|
57
|
+
* `VoicePipelineOrchestrator`, creates an instance, and injects the transport
|
|
58
|
+
* into `state.scratch.voiceTransport`.
|
|
59
59
|
* 3. Use `getNodeInput()` to obtain the user's transcribed speech for a node.
|
|
60
|
-
*
|
|
61
|
-
* 4. Use `deliverNodeOutput()` to send the node's response to TTS
|
|
60
|
+
* Delegates to `pipeline.waitForUserTurn()` when a pipeline is available.
|
|
61
|
+
* 4. Use `deliverNodeOutput()` to send the node's response to TTS via
|
|
62
|
+
* `pipeline.pushToTTS()`.
|
|
62
63
|
* 5. Call `dispose()` to clean up resources when the session ends.
|
|
63
|
-
*
|
|
64
|
-
* ## Error handling
|
|
65
|
-
*
|
|
66
|
-
* Both `getNodeInput()` and `deliverNodeOutput()` throw `Error` if called
|
|
67
|
-
* before `init()`. After `dispose()`, the adapter is marked as uninitialised
|
|
68
|
-
* so subsequent calls also throw.
|
|
69
|
-
*
|
|
70
|
-
* @see {@link VoiceTransportConfig} -- the config shape forwarded to the pipeline.
|
|
71
|
-
* See `VoiceNodeExecutor` for the executor that interacts with the transport.
|
|
72
64
|
*/
|
|
73
65
|
export class VoiceTransportAdapter {
|
|
74
66
|
/**
|
|
75
67
|
* Creates a new VoiceTransportAdapter.
|
|
76
68
|
*
|
|
77
|
-
* @param config - Voice pipeline configuration knobs.
|
|
78
|
-
*
|
|
79
|
-
* @param transport - Bidirectional audio/control stream transport
|
|
80
|
-
* (`IStreamTransport`). Must be an EventEmitter that
|
|
81
|
-
* emits `turn_complete` events for `getNodeInput()`.
|
|
69
|
+
* @param config - Voice pipeline configuration knobs.
|
|
70
|
+
* @param transport - Bidirectional audio/control stream transport (`IStreamTransport`).
|
|
82
71
|
* @param eventSink - Callback receiving all `GraphEvent` values emitted by
|
|
83
72
|
* this adapter. Must not throw.
|
|
84
73
|
*/
|
|
@@ -90,9 +79,8 @@ export class VoiceTransportAdapter {
|
|
|
90
79
|
/**
|
|
91
80
|
* Lazily-initialised `VoicePipelineOrchestrator` instance.
|
|
92
81
|
* Typed as `any` to avoid a hard import cycle with the voice subsystem.
|
|
93
|
-
* In a full implementation this would be `VoicePipelineOrchestrator | null`.
|
|
94
82
|
*/
|
|
95
|
-
this.pipeline = null;
|
|
83
|
+
this.pipeline = null;
|
|
96
84
|
/**
|
|
97
85
|
* Tracks whether `init()` has been called successfully.
|
|
98
86
|
* Set to `false` by `dispose()` to prevent use-after-teardown.
|
|
@@ -105,24 +93,30 @@ export class VoiceTransportAdapter {
|
|
|
105
93
|
/**
|
|
106
94
|
* Initialise the adapter.
|
|
107
95
|
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
* started event to signal that the voice session is live.
|
|
112
|
-
*
|
|
113
|
-
* Must be called exactly once before `getNodeInput()` or
|
|
114
|
-
* `deliverNodeOutput()`. Calling `init()` multiple times is safe but
|
|
115
|
-
* redundant -- the transport reference is simply overwritten.
|
|
116
|
-
*
|
|
117
|
-
* @param state - Mutable `GraphState` (or partial) for the current run.
|
|
118
|
-
* `state.scratch` is created lazily if absent.
|
|
96
|
+
* Lazily imports `VoicePipelineOrchestrator`, creates an instance from config,
|
|
97
|
+
* injects the transport into `state.scratch.voiceTransport`, and emits a
|
|
98
|
+
* `voice_session` started event.
|
|
119
99
|
*/
|
|
120
100
|
async init(state) {
|
|
121
101
|
var _a;
|
|
122
|
-
// Lazily create the scratch bag if the caller passed a partial state
|
|
123
|
-
// without a pre-existing scratch object.
|
|
124
102
|
const scratch = ((_a = state).scratch ?? (_a.scratch = {}));
|
|
125
103
|
scratch.voiceTransport = this.transport;
|
|
104
|
+
// Lazily import to avoid hard dependency cycle with the voice subsystem
|
|
105
|
+
try {
|
|
106
|
+
const { VoicePipelineOrchestrator } = await import('../../voice-pipeline/VoicePipelineOrchestrator.js');
|
|
107
|
+
this.pipeline = new VoicePipelineOrchestrator({
|
|
108
|
+
stt: this.config.stt ?? 'deepgram',
|
|
109
|
+
tts: this.config.tts ?? 'elevenlabs',
|
|
110
|
+
endpointing: this.config.endpointing,
|
|
111
|
+
bargeIn: this.config.bargeIn,
|
|
112
|
+
voice: this.config.voice,
|
|
113
|
+
language: this.config.language,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
// Pipeline unavailable — fall back to transport-only mode
|
|
118
|
+
this.pipeline = null;
|
|
119
|
+
}
|
|
126
120
|
this.initialized = true;
|
|
127
121
|
this.eventSink({
|
|
128
122
|
type: 'voice_session',
|
|
@@ -130,33 +124,35 @@ export class VoiceTransportAdapter {
|
|
|
130
124
|
action: 'started',
|
|
131
125
|
});
|
|
132
126
|
}
|
|
127
|
+
// -------------------------------------------------------------------------
|
|
128
|
+
// Node I/O
|
|
129
|
+
// -------------------------------------------------------------------------
|
|
133
130
|
/**
|
|
134
131
|
* Wait for the user's next speech turn and return the transcript text.
|
|
135
132
|
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
* it listens for a single `'turn_complete'` event from the underlying transport
|
|
139
|
-
* and resolves with the transcript text.
|
|
140
|
-
*
|
|
141
|
-
* Also emits a {@link GraphEvent} of type `voice_turn_complete` so that the
|
|
142
|
-
* runtime event bus stays in sync with the transport-level turn lifecycle.
|
|
143
|
-
*
|
|
144
|
-
* @param nodeId - The id of the graph node requesting input; used to tag the
|
|
145
|
-
* emitted event for downstream filtering.
|
|
146
|
-
* @returns Resolved transcript string from the user's speech turn.
|
|
147
|
-
* @throws {Error} If called before `init()` or after `dispose()`.
|
|
133
|
+
* Delegates to `VoicePipelineOrchestrator.waitForUserTurn()` when a pipeline
|
|
134
|
+
* is available. Falls back to listening for `turn_complete` on the transport.
|
|
148
135
|
*/
|
|
149
136
|
async getNodeInput(nodeId) {
|
|
150
137
|
if (!this.initialized) {
|
|
151
138
|
throw new Error('VoiceTransportAdapter not initialized');
|
|
152
139
|
}
|
|
153
|
-
//
|
|
154
|
-
|
|
155
|
-
|
|
140
|
+
// Delegate to pipeline if available
|
|
141
|
+
if (this.pipeline?.waitForUserTurn) {
|
|
142
|
+
const turnEvent = await this.pipeline.waitForUserTurn();
|
|
143
|
+
const transcript = turnEvent?.transcript ?? '';
|
|
144
|
+
this.eventSink({
|
|
145
|
+
type: 'voice_turn_complete',
|
|
146
|
+
nodeId,
|
|
147
|
+
transcript,
|
|
148
|
+
turnIndex: 0,
|
|
149
|
+
endpointReason: turnEvent?.reason ?? 'unknown',
|
|
150
|
+
});
|
|
151
|
+
return transcript;
|
|
152
|
+
}
|
|
153
|
+
// Fallback: listen on transport directly
|
|
156
154
|
return new Promise((resolve) => {
|
|
157
155
|
this.transport.once('turn_complete', (evt) => {
|
|
158
|
-
// Accept both `transcript` and `text` fields for compatibility
|
|
159
|
-
// with different transport implementations.
|
|
160
156
|
const transcript = evt?.transcript ?? evt?.text ?? '';
|
|
161
157
|
this.eventSink({
|
|
162
158
|
type: 'voice_turn_complete',
|
|
@@ -172,27 +168,17 @@ export class VoiceTransportAdapter {
|
|
|
172
168
|
/**
|
|
173
169
|
* Deliver a node's text output to the TTS engine.
|
|
174
170
|
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
* this delegates to `VoicePipelineOrchestrator.pushToTTS(output)`.
|
|
178
|
-
*
|
|
179
|
-
* Emits a {@link GraphEvent} of type `voice_audio` (direction `'outbound'`)
|
|
180
|
-
* so that the runtime event bus records the TTS delivery.
|
|
181
|
-
*
|
|
182
|
-
* @param nodeId - The id of the graph node delivering the output; tags the
|
|
183
|
-
* emitted event for downstream filtering.
|
|
184
|
-
* @param _output - Text or async token stream to synthesise as speech.
|
|
185
|
-
* The underscore prefix indicates it is not yet consumed
|
|
186
|
-
* in the v1 stub implementation.
|
|
187
|
-
* @throws {Error} If called before `init()` or after `dispose()`.
|
|
171
|
+
* Delegates to `VoicePipelineOrchestrator.pushToTTS()` when a pipeline is
|
|
172
|
+
* available, then emits a `voice_audio` outbound GraphEvent.
|
|
188
173
|
*/
|
|
189
|
-
async deliverNodeOutput(nodeId,
|
|
174
|
+
async deliverNodeOutput(nodeId, output) {
|
|
190
175
|
if (!this.initialized) {
|
|
191
176
|
throw new Error('VoiceTransportAdapter not initialized');
|
|
192
177
|
}
|
|
193
|
-
//
|
|
194
|
-
|
|
195
|
-
|
|
178
|
+
// Delegate to pipeline TTS if available
|
|
179
|
+
if (this.pipeline?.pushToTTS) {
|
|
180
|
+
await this.pipeline.pushToTTS(output);
|
|
181
|
+
}
|
|
196
182
|
this.eventSink({
|
|
197
183
|
type: 'voice_audio',
|
|
198
184
|
nodeId,
|
|
@@ -207,12 +193,7 @@ export class VoiceTransportAdapter {
|
|
|
207
193
|
/**
|
|
208
194
|
* Handle a user barge-in at the transport level.
|
|
209
195
|
*
|
|
210
|
-
*
|
|
211
|
-
* speaking while the agent is mid-utterance. Emits a `voice_barge_in` event
|
|
212
|
-
* so that graph event consumers can react (e.g. cancel pending tool calls,
|
|
213
|
-
* stop TTS playback, or reroute the graph).
|
|
214
|
-
*
|
|
215
|
-
* @see {@link VoiceInterruptError} -- the structured error used inside the graph executor.
|
|
196
|
+
* Emits a `voice_barge_in` event so that graph event consumers can react.
|
|
216
197
|
*/
|
|
217
198
|
handleBargeIn() {
|
|
218
199
|
this.eventSink({
|
|
@@ -228,13 +209,13 @@ export class VoiceTransportAdapter {
|
|
|
228
209
|
/**
|
|
229
210
|
* Dispose the adapter and emit a `voice_session` ended event.
|
|
230
211
|
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
* This method is idempotent -- calling it multiple times simply re-emits the
|
|
235
|
-
* ended event and re-sets the initialised flag.
|
|
212
|
+
* Stops the pipeline if one was initialised, then marks the adapter as
|
|
213
|
+
* uninitialised so subsequent calls throw.
|
|
236
214
|
*/
|
|
237
215
|
async dispose() {
|
|
216
|
+
if (this.pipeline?.stopSession) {
|
|
217
|
+
await this.pipeline.stopSession('adapter-disposed');
|
|
218
|
+
}
|
|
238
219
|
this.eventSink({
|
|
239
220
|
type: 'voice_session',
|
|
240
221
|
nodeId: '__transport__',
|
|
@@ -242,6 +223,7 @@ export class VoiceTransportAdapter {
|
|
|
242
223
|
exitReason: 'transport-disposed',
|
|
243
224
|
});
|
|
244
225
|
this.initialized = false;
|
|
226
|
+
this.pipeline = null;
|
|
245
227
|
}
|
|
246
228
|
}
|
|
247
229
|
//# sourceMappingURL=VoiceTransportAdapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VoiceTransportAdapter.js","sourceRoot":"","sources":["../../../src/orchestration/runtime/VoiceTransportAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;
|
|
1
|
+
{"version":3,"file":"VoiceTransportAdapter.js","sourceRoot":"","s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