diff --git a/src/lib/geminiLive.ts b/src/lib/geminiLive.ts index 415c348..76af1ce 100644 --- a/src/lib/geminiLive.ts +++ b/src/lib/geminiLive.ts @@ -38,7 +38,7 @@ export interface WebSocketLike { send(data: unknown): void close(code?: number, reason?: string): void on(event: 'message', listener: (data: unknown) => void): void - on(event: 'close', listener: () => void): void + on(event: 'close', listener: (code?: number, reason?: unknown) => void): void on(event: 'error', listener: (err: unknown) => void): void on(event: 'open', listener: () => void): void } @@ -109,14 +109,17 @@ export function openGeminiLiveSession( } geminiWs.on('open', () => { + console.log('[T2] Gemini WS opened') try { geminiWs.send(buildSetupFrame()) + console.log('[T2] Setup frame sent') } catch { closeBoth(1011, 'SETUP_FAILED') } }) geminiWs.on('message', (data) => { + console.log('[T2] Gemini message received, type:', typeof data) try { clientWs.send(data) } catch { @@ -132,9 +135,15 @@ export function openGeminiLiveSession( } }) - geminiWs.on('close', () => closeBoth(1000)) + geminiWs.on('close', (code, reason) => { + console.log('[T2] Gemini closed, code:', code, 'reason:', reason) + closeBoth(1000) + }) clientWs.on('close', () => closeBoth(1000)) - geminiWs.on('error', () => closeBoth(1011, 'GEMINI_ERROR')) + geminiWs.on('error', (err) => { + console.log('[T2] Gemini error:', (err as Error)?.message) + closeBoth(1011, 'GEMINI_ERROR') + }) clientWs.on('error', () => closeBoth(1011, 'CLIENT_ERROR')) }