@devicai/ui 0.60.0 → 0.61.0
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/README.md +4 -0
- package/dist/cjs/api/client.js +38 -5
- package/dist/cjs/api/client.js.map +1 -1
- package/dist/cjs/api/types.js.map +1 -1
- package/dist/cjs/components/ChatDrawer/ChatDrawer.js +9 -2
- package/dist/cjs/components/ChatDrawer/ChatDrawer.js.map +1 -1
- package/dist/cjs/components/ChatDrawer/ChatMessages.js +2 -1
- package/dist/cjs/components/ChatDrawer/ChatMessages.js.map +1 -1
- package/dist/cjs/components/ChatDrawer/LiveVoicePanel.js +106 -0
- package/dist/cjs/components/ChatDrawer/LiveVoicePanel.js.map +1 -0
- package/dist/cjs/components/ChatDrawer/LiveVoicePrompter.js +148 -0
- package/dist/cjs/components/ChatDrawer/LiveVoicePrompter.js.map +1 -0
- package/dist/cjs/hooks/useDevicChat.js +68 -17
- package/dist/cjs/hooks/useDevicChat.js.map +1 -1
- package/dist/cjs/hooks/useDevicLiveVoice.js +73 -0
- package/dist/cjs/hooks/useDevicLiveVoice.js.map +1 -0
- package/dist/cjs/hooks/usePolling.js +1 -1
- package/dist/cjs/hooks/usePolling.js.map +1 -1
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/styles.css +1 -1
- package/dist/cjs/voice/LiveVoiceController.js +287 -0
- package/dist/cjs/voice/LiveVoiceController.js.map +1 -0
- package/dist/esm/api/client.d.ts +12 -3
- package/dist/esm/api/client.js +38 -5
- package/dist/esm/api/client.js.map +1 -1
- package/dist/esm/api/liveVoice.types.d.ts +49 -0
- package/dist/esm/api/types.d.ts +3 -0
- package/dist/esm/api/types.js.map +1 -1
- package/dist/esm/components/ChatDrawer/ChatDrawer.js +11 -4
- package/dist/esm/components/ChatDrawer/ChatDrawer.js.map +1 -1
- package/dist/esm/components/ChatDrawer/ChatDrawer.types.d.ts +6 -0
- package/dist/esm/components/ChatDrawer/ChatMessages.js +2 -1
- package/dist/esm/components/ChatDrawer/ChatMessages.js.map +1 -1
- package/dist/esm/components/ChatDrawer/LiveVoicePanel.d.ts +21 -0
- package/dist/esm/components/ChatDrawer/LiveVoicePanel.js +102 -0
- package/dist/esm/components/ChatDrawer/LiveVoicePanel.js.map +1 -0
- package/dist/esm/components/ChatDrawer/LiveVoicePrompter.d.ts +12 -0
- package/dist/esm/components/ChatDrawer/LiveVoicePrompter.js +145 -0
- package/dist/esm/components/ChatDrawer/LiveVoicePrompter.js.map +1 -0
- package/dist/esm/hooks/index.d.ts +2 -0
- package/dist/esm/hooks/useDevicChat.d.ts +6 -0
- package/dist/esm/hooks/useDevicChat.js +68 -17
- package/dist/esm/hooks/useDevicChat.js.map +1 -1
- package/dist/esm/hooks/useDevicLiveVoice.d.ts +20 -0
- package/dist/esm/hooks/useDevicLiveVoice.js +71 -0
- package/dist/esm/hooks/useDevicLiveVoice.js.map +1 -0
- package/dist/esm/hooks/usePolling.d.ts +1 -1
- package/dist/esm/hooks/usePolling.js +1 -1
- package/dist/esm/hooks/usePolling.js.map +1 -1
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/styles.css +1 -1
- package/dist/esm/voice/LiveVoiceController.d.ts +38 -0
- package/dist/esm/voice/LiveVoiceController.js +284 -0
- package/dist/esm/voice/LiveVoiceController.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
const initialVoiceSnapshot = () => ({ state: 'idle', muted: false, seconds: 0, transcript: [] });
|
|
2
|
+
/** No browser globals at import/constructor time; loaded only by start(). */
|
|
3
|
+
class LiveVoiceController {
|
|
4
|
+
constructor(client, assistantId, context, changed, created) {
|
|
5
|
+
this.client = client;
|
|
6
|
+
this.assistantId = assistantId;
|
|
7
|
+
this.context = context;
|
|
8
|
+
this.changed = changed;
|
|
9
|
+
this.created = created;
|
|
10
|
+
this.snapshot = initialVoiceSnapshot();
|
|
11
|
+
this.generation = 0;
|
|
12
|
+
this.attempts = 0;
|
|
13
|
+
this.disposeTransport = () => { };
|
|
14
|
+
this.disposed = false;
|
|
15
|
+
}
|
|
16
|
+
update(patch) {
|
|
17
|
+
this.snapshot = { ...this.snapshot, ...patch };
|
|
18
|
+
if (!this.disposed)
|
|
19
|
+
this.changed(this.snapshot);
|
|
20
|
+
}
|
|
21
|
+
mute(muted) {
|
|
22
|
+
this.snapshot.input?.getAudioTracks().forEach(track => { track.enabled = !muted && this.snapshot.state === 'connected'; });
|
|
23
|
+
this.update({ muted });
|
|
24
|
+
}
|
|
25
|
+
async play() {
|
|
26
|
+
try {
|
|
27
|
+
await this.audio?.play();
|
|
28
|
+
this.update({ playbackBlocked: false });
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
this.update({ playbackBlocked: true });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async start(chatUid, recovering = false) {
|
|
35
|
+
if (this.disposed || this.closing || (!recovering && !['idle', 'error'].includes(this.snapshot.state)))
|
|
36
|
+
return;
|
|
37
|
+
const generation = ++this.generation;
|
|
38
|
+
const current = () => generation === this.generation && !this.disposed;
|
|
39
|
+
if (!recovering)
|
|
40
|
+
this.attempts = 0;
|
|
41
|
+
this.update({ state: 'connecting', error: undefined, chatUid, sessionId: undefined,
|
|
42
|
+
seconds: 0, ...(recovering ? {} : { transcript: [], muted: false }) });
|
|
43
|
+
let media;
|
|
44
|
+
let peer;
|
|
45
|
+
let channel;
|
|
46
|
+
let audio;
|
|
47
|
+
let health;
|
|
48
|
+
let deadline;
|
|
49
|
+
let connectDeadline;
|
|
50
|
+
let backendReady = false;
|
|
51
|
+
let lastTranscript = 0;
|
|
52
|
+
let sessionId;
|
|
53
|
+
let connectionLostAt = 0;
|
|
54
|
+
let healthFailures = 0;
|
|
55
|
+
const cleanup = () => {
|
|
56
|
+
clearInterval(health);
|
|
57
|
+
clearTimeout(deadline);
|
|
58
|
+
clearTimeout(connectDeadline);
|
|
59
|
+
media?.getTracks().forEach(track => track.stop());
|
|
60
|
+
if (channel) {
|
|
61
|
+
channel.onclose = null;
|
|
62
|
+
channel.onmessage = null;
|
|
63
|
+
channel.close();
|
|
64
|
+
}
|
|
65
|
+
if (peer) {
|
|
66
|
+
peer.onconnectionstatechange = null;
|
|
67
|
+
peer.ontrack = null;
|
|
68
|
+
peer.close();
|
|
69
|
+
}
|
|
70
|
+
if (audio) {
|
|
71
|
+
audio.pause();
|
|
72
|
+
audio.srcObject = null;
|
|
73
|
+
}
|
|
74
|
+
this.audio = undefined;
|
|
75
|
+
this.update({ input: undefined, output: undefined });
|
|
76
|
+
};
|
|
77
|
+
this.disposeTransport = cleanup;
|
|
78
|
+
const ready = () => {
|
|
79
|
+
if (!current() || !backendReady || peer?.connectionState !== 'connected')
|
|
80
|
+
return;
|
|
81
|
+
clearTimeout(connectDeadline);
|
|
82
|
+
media?.getAudioTracks().forEach(track => { track.enabled = !this.snapshot.muted; });
|
|
83
|
+
this.update({ state: 'connected' });
|
|
84
|
+
};
|
|
85
|
+
const recover = async () => {
|
|
86
|
+
if (!current())
|
|
87
|
+
return;
|
|
88
|
+
++this.generation;
|
|
89
|
+
const ticket = this.generation;
|
|
90
|
+
cleanup();
|
|
91
|
+
this.update({ state: 'reconnecting' });
|
|
92
|
+
try {
|
|
93
|
+
if (!sessionId || ++this.attempts > 3)
|
|
94
|
+
throw new Error('Voice connection interrupted. Please start again.');
|
|
95
|
+
await this.client.closeLiveSession(this.assistantId, sessionId);
|
|
96
|
+
// Never open another paid transport before the old one is confirmed closed.
|
|
97
|
+
for (let i = 0; i < 35 && ticket === this.generation && !this.disposed; i++) {
|
|
98
|
+
const state = await this.client.getLiveSessionStatus(this.assistantId, sessionId);
|
|
99
|
+
if (state.status === 'closed') {
|
|
100
|
+
if (ticket === this.generation && !this.disposed)
|
|
101
|
+
await this.start(this.snapshot.chatUid, true);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
105
|
+
}
|
|
106
|
+
if (ticket === this.generation)
|
|
107
|
+
throw new Error('Could not confirm the previous voice session closed.');
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
if (ticket === this.generation)
|
|
111
|
+
this.update({ state: 'error', error: error });
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
try {
|
|
115
|
+
if (typeof navigator === 'undefined' || !navigator.mediaDevices?.getUserMedia || typeof RTCPeerConnection === 'undefined')
|
|
116
|
+
throw new Error('Voice requires microphone access on HTTPS or localhost.');
|
|
117
|
+
media = await navigator.mediaDevices.getUserMedia({ audio: { echoCancellation: true }, video: false });
|
|
118
|
+
if (!current()) {
|
|
119
|
+
media.getTracks().forEach(track => track.stop());
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
media.getAudioTracks().forEach(track => { track.enabled = false; });
|
|
123
|
+
this.update({ input: media });
|
|
124
|
+
peer = new RTCPeerConnection({ bundlePolicy: 'max-bundle' });
|
|
125
|
+
audio = new Audio();
|
|
126
|
+
this.audio = audio;
|
|
127
|
+
audio.autoplay = true;
|
|
128
|
+
peer.ontrack = event => {
|
|
129
|
+
if (!current())
|
|
130
|
+
return;
|
|
131
|
+
const output = new MediaStream([event.track]);
|
|
132
|
+
audio.srcObject = output;
|
|
133
|
+
this.update({ output });
|
|
134
|
+
void this.play();
|
|
135
|
+
};
|
|
136
|
+
peer.onconnectionstatechange = () => {
|
|
137
|
+
ready();
|
|
138
|
+
if (peer?.connectionState === 'disconnected')
|
|
139
|
+
connectionLostAt || (connectionLostAt = Date.now());
|
|
140
|
+
else
|
|
141
|
+
connectionLostAt = 0;
|
|
142
|
+
if (peer?.connectionState === 'failed')
|
|
143
|
+
void recover();
|
|
144
|
+
};
|
|
145
|
+
media.getTracks().forEach(track => peer.addTrack(track, media));
|
|
146
|
+
channel = peer.createDataChannel('oai-events');
|
|
147
|
+
channel.onmessage = message => {
|
|
148
|
+
if (!current())
|
|
149
|
+
return;
|
|
150
|
+
try {
|
|
151
|
+
const event = JSON.parse(message.data);
|
|
152
|
+
if (event.type === 'session.started') {
|
|
153
|
+
backendReady = true;
|
|
154
|
+
ready();
|
|
155
|
+
}
|
|
156
|
+
if (['session.input_transcript.delta', 'session.output_transcript.delta'].includes(event.type) && typeof event.delta === 'string') {
|
|
157
|
+
lastTranscript = Date.now();
|
|
158
|
+
const role = event.type === 'session.input_transcript.delta' ? 'user' : 'assistant';
|
|
159
|
+
const turns = this.snapshot.transcript.slice(-3).map(turn => ({ ...turn }));
|
|
160
|
+
if (turns[turns.length - 1]?.role === role)
|
|
161
|
+
turns[turns.length - 1].text = (turns[turns.length - 1].text + event.delta).slice(-2000);
|
|
162
|
+
else
|
|
163
|
+
turns.push({ role, text: event.delta.slice(-2000) });
|
|
164
|
+
this.update({ transcript: turns });
|
|
165
|
+
}
|
|
166
|
+
if (event.type === 'session.closed' && sessionId) {
|
|
167
|
+
void this.client.getLiveSessionStatus(this.assistantId, sessionId).then(state => {
|
|
168
|
+
if (!current())
|
|
169
|
+
return;
|
|
170
|
+
if (state.restartRequested)
|
|
171
|
+
void recover();
|
|
172
|
+
else
|
|
173
|
+
void this.stop();
|
|
174
|
+
}).catch(() => { if (current())
|
|
175
|
+
void this.stop(); });
|
|
176
|
+
}
|
|
177
|
+
if (event.type === 'error') {
|
|
178
|
+
this.update({ error: new Error('Voice session failed.') });
|
|
179
|
+
void this.stop();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
catch { /* Only lifecycle and spoken transcript events are accepted. */ }
|
|
183
|
+
};
|
|
184
|
+
channel.onclose = () => { if (current())
|
|
185
|
+
void recover(); };
|
|
186
|
+
connectDeadline = setTimeout(() => {
|
|
187
|
+
if (current()) {
|
|
188
|
+
this.update({ error: new Error('Voice connection timed out.') });
|
|
189
|
+
void this.stop();
|
|
190
|
+
}
|
|
191
|
+
}, 30000);
|
|
192
|
+
await peer.setLocalDescription(await peer.createOffer());
|
|
193
|
+
await new Promise((resolve, reject) => {
|
|
194
|
+
if (peer.iceGatheringState === 'complete')
|
|
195
|
+
return resolve();
|
|
196
|
+
const done = () => {
|
|
197
|
+
if (peer.iceGatheringState !== 'complete')
|
|
198
|
+
return;
|
|
199
|
+
clearTimeout(timer);
|
|
200
|
+
peer.removeEventListener('icegatheringstatechange', done);
|
|
201
|
+
resolve();
|
|
202
|
+
};
|
|
203
|
+
const timer = setTimeout(() => { peer.removeEventListener('icegatheringstatechange', done); reject(new Error('Could not prepare the audio connection.')); }, 10000);
|
|
204
|
+
peer.addEventListener('icegatheringstatechange', done);
|
|
205
|
+
});
|
|
206
|
+
if (!current())
|
|
207
|
+
return;
|
|
208
|
+
const result = await this.client.createLiveSession(this.assistantId, { ...this.context, chatUid, sdp: peer.localDescription.sdp });
|
|
209
|
+
sessionId = result.sessionId;
|
|
210
|
+
if (!current()) {
|
|
211
|
+
void this.client.closeLiveSession(this.assistantId, sessionId).catch(() => { });
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
this.update({ sessionId, chatUid: result.chatUid });
|
|
215
|
+
this.created(result.chatUid);
|
|
216
|
+
deadline = setTimeout(() => { void this.stop(); }, Math.max(1, Math.min(6000, result.maxDurationSeconds || 6000)) * 1000);
|
|
217
|
+
await peer.setRemoteDescription({ type: 'answer', sdp: result.sdp });
|
|
218
|
+
let busy = false;
|
|
219
|
+
health = setInterval(async () => {
|
|
220
|
+
if (!current() || busy)
|
|
221
|
+
return;
|
|
222
|
+
busy = true;
|
|
223
|
+
try {
|
|
224
|
+
const state = await this.client.getLiveSessionStatus(this.assistantId, sessionId);
|
|
225
|
+
if (!current())
|
|
226
|
+
return;
|
|
227
|
+
healthFailures = 0;
|
|
228
|
+
this.update({ seconds: state.seconds });
|
|
229
|
+
if (state.interrupted || state.restartRequested || (connectionLostAt && Date.now() - connectionLostAt > 5000)) {
|
|
230
|
+
void recover();
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
if (state.status === 'closed') {
|
|
234
|
+
void this.stop();
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
backendReady = state.connected;
|
|
238
|
+
ready();
|
|
239
|
+
if (Date.now() - lastTranscript > 1500 && state.transcript?.length)
|
|
240
|
+
this.update({ transcript: state.transcript.slice(-4).filter(t => t.role === 'user' || t.role === 'assistant').map(t => ({ role: t.role, text: t.text.slice(-2000) })) });
|
|
241
|
+
}
|
|
242
|
+
catch {
|
|
243
|
+
if (current() && ++healthFailures >= 5) {
|
|
244
|
+
this.update({ error: new Error('Voice status unavailable. Session stopped.') });
|
|
245
|
+
void this.stop();
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
finally {
|
|
249
|
+
busy = false;
|
|
250
|
+
}
|
|
251
|
+
}, 1000);
|
|
252
|
+
}
|
|
253
|
+
catch (error) {
|
|
254
|
+
if (!current())
|
|
255
|
+
return;
|
|
256
|
+
this.update({ error: error instanceof Error ? error : new Error(String(error)) });
|
|
257
|
+
await this.stop();
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
stop() {
|
|
261
|
+
if (this.closing)
|
|
262
|
+
return this.closing;
|
|
263
|
+
++this.generation;
|
|
264
|
+
this.disposeTransport();
|
|
265
|
+
const id = this.snapshot.sessionId;
|
|
266
|
+
this.update({ state: id ? 'closing' : (this.snapshot.error ? 'error' : 'idle') });
|
|
267
|
+
this.closing = (async () => {
|
|
268
|
+
if (id) {
|
|
269
|
+
try {
|
|
270
|
+
await this.client.closeLiveSession(this.assistantId, id);
|
|
271
|
+
}
|
|
272
|
+
catch (error) {
|
|
273
|
+
this.update({ error: error });
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
this.update({ state: this.snapshot.error ? 'error' : 'idle', sessionId: undefined });
|
|
277
|
+
})().finally(() => { this.closing = undefined; });
|
|
278
|
+
return this.closing;
|
|
279
|
+
}
|
|
280
|
+
dispose() { this.disposed = true; void this.stop(); }
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export { LiveVoiceController, initialVoiceSnapshot };
|
|
284
|
+
//# sourceMappingURL=LiveVoiceController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LiveVoiceController.js","sources":["../../../src/voice/LiveVoiceController.ts"],"sourcesContent":["import type { DevicApiClient } from '../api/client';\nimport type { LiveVoiceContext, LiveVoiceTurn } from '../api/liveVoice.types';\n\nexport type LiveVoiceState = 'idle' | 'connecting' | 'connected' | 'reconnecting' | 'closing' | 'error';\nexport interface LiveVoiceSnapshot {\n state: LiveVoiceState;\n chatUid?: string;\n sessionId?: string;\n muted: boolean;\n seconds: number;\n transcript: LiveVoiceTurn[];\n input?: MediaStream;\n output?: MediaStream;\n error?: Error;\n playbackBlocked?: boolean;\n}\nexport const initialVoiceSnapshot = (): LiveVoiceSnapshot => ({ state: 'idle', muted: false, seconds: 0, transcript: [] });\n\n/** No browser globals at import/constructor time; loaded only by start(). */\nexport class LiveVoiceController {\n private snapshot = initialVoiceSnapshot();\n private generation = 0;\n private attempts = 0;\n private disposeTransport: () => void = () => {};\n private audio?: HTMLAudioElement;\n private closing?: Promise<void>;\n private disposed = false;\n constructor(private client: DevicApiClient, private assistantId: string,\n private context: LiveVoiceContext, private changed: (value: LiveVoiceSnapshot) => void,\n private created: (chatUid: string) => void) {}\n\n private update(patch: Partial<LiveVoiceSnapshot>) {\n this.snapshot = { ...this.snapshot, ...patch };\n if (!this.disposed) this.changed(this.snapshot);\n }\n mute(muted: boolean) {\n this.snapshot.input?.getAudioTracks().forEach(track => { track.enabled = !muted && this.snapshot.state === 'connected'; });\n this.update({ muted });\n }\n async play() {\n try { await this.audio?.play(); this.update({ playbackBlocked: false }); }\n catch { this.update({ playbackBlocked: true }); }\n }\n async start(chatUid?: string, recovering = false): Promise<void> {\n if (this.disposed || this.closing || (!recovering && !['idle', 'error'].includes(this.snapshot.state))) return;\n const generation = ++this.generation;\n const current = () => generation === this.generation && !this.disposed;\n if (!recovering) this.attempts = 0;\n this.update({ state: 'connecting', error: undefined, chatUid, sessionId: undefined,\n seconds: 0, ...(recovering ? {} : { transcript: [], muted: false }) });\n let media: MediaStream | undefined;\n let peer: RTCPeerConnection | undefined;\n let channel: RTCDataChannel | undefined;\n let audio: HTMLAudioElement | undefined;\n let health: ReturnType<typeof setInterval> | undefined;\n let deadline: ReturnType<typeof setTimeout> | undefined;\n let connectDeadline: ReturnType<typeof setTimeout> | undefined;\n let backendReady = false;\n let lastTranscript = 0;\n let sessionId: string | undefined;\n let connectionLostAt = 0;\n let healthFailures = 0;\n const cleanup = () => {\n clearInterval(health); clearTimeout(deadline); clearTimeout(connectDeadline);\n media?.getTracks().forEach(track => track.stop());\n if (channel) { channel.onclose = null; channel.onmessage = null; channel.close(); }\n if (peer) { peer.onconnectionstatechange = null; peer.ontrack = null; peer.close(); }\n if (audio) { audio.pause(); audio.srcObject = null; }\n this.audio = undefined;\n this.update({ input: undefined, output: undefined });\n };\n this.disposeTransport = cleanup;\n const ready = () => {\n if (!current() || !backendReady || peer?.connectionState !== 'connected') return;\n clearTimeout(connectDeadline);\n media?.getAudioTracks().forEach(track => { track.enabled = !this.snapshot.muted; });\n this.update({ state: 'connected' });\n };\n const recover = async () => {\n if (!current()) return;\n ++this.generation;\n const ticket = this.generation;\n cleanup();\n this.update({ state: 'reconnecting' });\n try {\n if (!sessionId || ++this.attempts > 3) throw new Error('Voice connection interrupted. Please start again.');\n await this.client.closeLiveSession(this.assistantId, sessionId);\n // Never open another paid transport before the old one is confirmed closed.\n for (let i = 0; i < 35 && ticket === this.generation && !this.disposed; i++) {\n const state = await this.client.getLiveSessionStatus(this.assistantId, sessionId);\n if (state.status === 'closed') {\n if (ticket === this.generation && !this.disposed) await this.start(this.snapshot.chatUid, true);\n return;\n }\n await new Promise(resolve => setTimeout(resolve, 2000));\n }\n if (ticket === this.generation) throw new Error('Could not confirm the previous voice session closed.');\n } catch (error) {\n if (ticket === this.generation) this.update({ state: 'error', error: error as Error });\n }\n };\n try {\n if (typeof navigator === 'undefined' || !navigator.mediaDevices?.getUserMedia || typeof RTCPeerConnection === 'undefined')\n throw new Error('Voice requires microphone access on HTTPS or localhost.');\n media = await navigator.mediaDevices.getUserMedia({ audio: { echoCancellation: true }, video: false });\n if (!current()) { media.getTracks().forEach(track => track.stop()); return; }\n media.getAudioTracks().forEach(track => { track.enabled = false; });\n this.update({ input: media });\n peer = new RTCPeerConnection({ bundlePolicy: 'max-bundle' });\n audio = new Audio(); this.audio = audio; audio.autoplay = true;\n peer.ontrack = event => {\n if (!current()) return;\n const output = new MediaStream([event.track]);\n audio!.srcObject = output;\n this.update({ output }); void this.play();\n };\n peer.onconnectionstatechange = () => {\n ready();\n if (peer?.connectionState === 'disconnected') connectionLostAt ||= Date.now();\n else connectionLostAt = 0;\n if (peer?.connectionState === 'failed') void recover();\n };\n media.getTracks().forEach(track => peer!.addTrack(track, media!));\n channel = peer.createDataChannel('oai-events');\n channel.onmessage = message => {\n if (!current()) return;\n try {\n const event = JSON.parse(message.data);\n if (event.type === 'session.started') { backendReady = true; ready(); }\n if (['session.input_transcript.delta', 'session.output_transcript.delta'].includes(event.type) && typeof event.delta === 'string') {\n lastTranscript = Date.now();\n const role = event.type === 'session.input_transcript.delta' ? 'user' : 'assistant';\n const turns = this.snapshot.transcript.slice(-3).map(turn => ({ ...turn }));\n if (turns[turns.length - 1]?.role === role) turns[turns.length - 1].text = (turns[turns.length - 1].text + event.delta).slice(-2000);\n else turns.push({ role, text: event.delta.slice(-2000) });\n this.update({ transcript: turns });\n }\n if (event.type === 'session.closed' && sessionId) {\n void this.client.getLiveSessionStatus(this.assistantId, sessionId).then(state => {\n if (!current()) return;\n if (state.restartRequested) void recover(); else void this.stop();\n }).catch(() => { if (current()) void this.stop(); });\n }\n if (event.type === 'error') { this.update({ error: new Error('Voice session failed.') }); void this.stop(); }\n } catch { /* Only lifecycle and spoken transcript events are accepted. */ }\n };\n channel.onclose = () => { if (current()) void recover(); };\n connectDeadline = setTimeout(() => {\n if (current()) { this.update({ error: new Error('Voice connection timed out.') }); void this.stop(); }\n }, 30000);\n await peer.setLocalDescription(await peer.createOffer());\n await new Promise<void>((resolve, reject) => {\n if (peer!.iceGatheringState === 'complete') return resolve();\n const done = () => {\n if (peer!.iceGatheringState !== 'complete') return;\n clearTimeout(timer); peer!.removeEventListener('icegatheringstatechange', done); resolve();\n };\n const timer = setTimeout(() => { peer!.removeEventListener('icegatheringstatechange', done); reject(new Error('Could not prepare the audio connection.')); }, 10000);\n peer!.addEventListener('icegatheringstatechange', done);\n });\n if (!current()) return;\n const result = await this.client.createLiveSession(this.assistantId, { ...this.context, chatUid, sdp: peer.localDescription!.sdp });\n sessionId = result.sessionId;\n if (!current()) { void this.client.closeLiveSession(this.assistantId, sessionId).catch(() => {}); return; }\n this.update({ sessionId, chatUid: result.chatUid }); this.created(result.chatUid);\n deadline = setTimeout(() => { void this.stop(); }, Math.max(1, Math.min(6000, result.maxDurationSeconds || 6000)) * 1000);\n await peer.setRemoteDescription({ type: 'answer', sdp: result.sdp });\n let busy = false;\n health = setInterval(async () => {\n if (!current() || busy) return;\n busy = true;\n try {\n const state = await this.client.getLiveSessionStatus(this.assistantId, sessionId!);\n if (!current()) return;\n healthFailures = 0;\n this.update({ seconds: state.seconds });\n if (state.interrupted || state.restartRequested || (connectionLostAt && Date.now() - connectionLostAt > 5000)) { void recover(); return; }\n if (state.status === 'closed') { void this.stop(); return; }\n backendReady = state.connected; ready();\n if (Date.now() - lastTranscript > 1500 && state.transcript?.length)\n this.update({ transcript: state.transcript.slice(-4).filter(t => t.role === 'user' || t.role === 'assistant').map(t => ({ role: t.role, text: t.text.slice(-2000) })) });\n } catch {\n if (current() && ++healthFailures >= 5) { this.update({ error: new Error('Voice status unavailable. Session stopped.')} ); void this.stop(); }\n } finally { busy = false; }\n }, 1000);\n } catch (error) {\n if (!current()) return;\n this.update({ error: error instanceof Error ? error : new Error(String(error)) });\n await this.stop();\n }\n }\n stop(): Promise<void> {\n if (this.closing) return this.closing;\n ++this.generation;\n this.disposeTransport();\n const id = this.snapshot.sessionId;\n this.update({ state: id ? 'closing' : (this.snapshot.error ? 'error' : 'idle') });\n this.closing = (async () => {\n if (id) {\n try { await this.client.closeLiveSession(this.assistantId, id); }\n catch (error) { this.update({ error: error as Error }); }\n }\n this.update({ state: this.snapshot.error ? 'error' : 'idle', sessionId: undefined });\n })().finally(() => { this.closing = undefined; });\n return this.closing;\n }\n dispose() { this.disposed = true; void this.stop(); }\n}\n"],"names":[],"mappings":"AAgBO,MAAM,oBAAoB,GAAG,OAA0B,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE;AAEzH;MACa,mBAAmB,CAAA;IAQ9B,WAAA,CAAoB,MAAsB,EAAU,WAAmB,EAC7D,OAAyB,EAAU,OAA2C,EAC9E,OAAkC,EAAA;QAFxB,IAAA,CAAA,MAAM,GAAN,MAAM;QAA0B,IAAA,CAAA,WAAW,GAAX,WAAW;QACrD,IAAA,CAAA,OAAO,GAAP,OAAO;QAA4B,IAAA,CAAA,OAAO,GAAP,OAAO;QAC1C,IAAA,CAAA,OAAO,GAAP,OAAO;QATT,IAAA,CAAA,QAAQ,GAAG,oBAAoB,EAAE;QACjC,IAAA,CAAA,UAAU,GAAG,CAAC;QACd,IAAA,CAAA,QAAQ,GAAG,CAAC;AACZ,QAAA,IAAA,CAAA,gBAAgB,GAAe,MAAK,EAAE,CAAC;QAGvC,IAAA,CAAA,QAAQ,GAAG,KAAK;IAGuB;AAEvC,IAAA,MAAM,CAAC,KAAiC,EAAA;AAC9C,QAAA,IAAI,CAAC,QAAQ,GAAG,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,KAAK,EAAE;QAC9C,IAAI,CAAC,IAAI,CAAC,QAAQ;AAAE,YAAA,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;IACjD;AACA,IAAA,IAAI,CAAC,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