Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .claude/skills/nexus-llm-adapters/references/symptoms.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ end quietly. Treat missing output as a swallowed failure until proven otherwise.
| Streaming works on desktop, single blob on mobile | Expected. Without a Node runtime, `requestStream()` falls back to a buffered request wrapped as a one-chunk stream. | `streaming-contract.md` |
| Settings still says “Connected” after ChatGPT rejects a Codex refresh token | The inference adapter can fail authentication without updating the persisted OAuth state. Handle only a confirmed invalid refresh token as a disconnect, persist a reconnect marker through the provider driver, and show the reconnect action in the provider modal. Do not disconnect on a temporary network or server failure. | `src/services/llm/adapters/openai-codex/OpenAICodexAdapter.ts`, `src/services/llm/providers/BuiltinProviderDrivers.ts` |
| A tool says `Request failed, status 4xx` with no explanation | A bare `requestUrl` throws on non-2xx and discards the body; Jest's mock hides this | Call `ProviderHttpClient.requestOk` with `provider` and `operation`. It keeps the provider's message and reports a missing permission as such. Pass `responseType: 'binary'` for media. |
| A speech model changes but the adapter still writes its own WAV header | The provider can return a complete RIFF/WAVE file where its previews returned raw PCM. Inspect the decoded bytes and wrap only PCM. Test with a complete WAV and require byte-for-byte preservation. | `src/services/readAloud/GoogleSpeechAdapter.ts`, `tests/unit/SpeechSynthesisService.test.ts` |

## When the symptom is not here
Debug it, fix it, then add the row. `protocols/self-refine.md` step 2 exists for
Expand Down
2 changes: 2 additions & 0 deletions .claude/skills/nexus-llm-adapters/refinement-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,5 @@ to 0). Edit `.skills/` and run `npm run sync:skills`; never edit a mirror. |
- 2026-11-10 | Gemini 4 sibling required extending exact-model request guards; existing model-update routing protocol identified every guard. No adapter skill procedure change.

- 2026-11-18: A newly listed Google family member would fall through exact model-id checks to an invalid legacy thinking budget. Encoded its contract in ModelSpec and tested both request paths; existing skill protocols already direct this check, no procedure change.

- 2026-11-20: The speech adapter wrapped an already formatted WAV in a second header. Added the response-format check and regression approach to `references/symptoms.md`.
2 changes: 2 additions & 0 deletions .claude/skills/nexus-model-updates/refinement-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,5 @@ Append-only record of changes made by `protocols/self-refine.md`. Newest on top.
- 2026-11-18: Added registry-anatomy guidance for googleGeneration so new models declare supported thinking levels and separate buffered/streaming foreground limits.

- 2026-11-19: Added a provider-listed model using the existing generation declaration and request-contract tests; no skill procedure change needed.

- 2026-11-20: Verified the published Gemini audio shutdown dates and exercised the saved-selection migration. The existing billing guidance covered the rejected provider probes. No procedure change.
2 changes: 2 additions & 0 deletions .claude/skills/nexus-testing/refinement-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,5 @@ Verified the installed 5.21.3 candidate in Nexus Redesign Test with matching art
- 2026-11-19: Added a provider-listed model using the existing generation declaration and request-contract tests; no skill procedure change needed.

- 2026-11-19: Confirmed Linux Obsidian1.15.1 needs command-first vault targeting for eval; documented argument order and native settings-window capture in live-loop.md.

- 2026-11-20: Verified the migration and WAV regression tests failed against the previous implementation. Ran the installed Jest binary directly after `pnpm exec` attempted to convert the npm installation. No procedure change.
1 change: 1 addition & 0 deletions .cline/skills/nexus-llm-adapters/references/symptoms.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ end quietly. Treat missing output as a swallowed failure until proven otherwise.
| Streaming works on desktop, single blob on mobile | Expected. Without a Node runtime, `requestStream()` falls back to a buffered request wrapped as a one-chunk stream. | `streaming-contract.md` |
| Settings still says “Connected” after ChatGPT rejects a Codex refresh token | The inference adapter can fail authentication without updating the persisted OAuth state. Handle only a confirmed invalid refresh token as a disconnect, persist a reconnect marker through the provider driver, and show the reconnect action in the provider modal. Do not disconnect on a temporary network or server failure. | `src/services/llm/adapters/openai-codex/OpenAICodexAdapter.ts`, `src/services/llm/providers/BuiltinProviderDrivers.ts` |
| A tool says `Request failed, status 4xx` with no explanation | A bare `requestUrl` throws on non-2xx and discards the body; Jest's mock hides this | Call `ProviderHttpClient.requestOk` with `provider` and `operation`. It keeps the provider's message and reports a missing permission as such. Pass `responseType: 'binary'` for media. |
| A speech model changes but the adapter still writes its own WAV header | The provider can return a complete RIFF/WAVE file where its previews returned raw PCM. Inspect the decoded bytes and wrap only PCM. Test with a complete WAV and require byte-for-byte preservation. | `src/services/readAloud/GoogleSpeechAdapter.ts`, `tests/unit/SpeechSynthesisService.test.ts` |

## When the symptom is not here
Debug it, fix it, then add the row. `protocols/self-refine.md` step 2 exists for
Expand Down
2 changes: 2 additions & 0 deletions .cline/skills/nexus-llm-adapters/refinement-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,5 @@ to 0). Edit `.skills/` and run `npm run sync:skills`; never edit a mirror. |
- 2026-11-10 | Gemini 4 sibling required extending exact-model request guards; existing model-update routing protocol identified every guard. No adapter skill procedure change.

- 2026-11-18: A newly listed Google family member would fall through exact model-id checks to an invalid legacy thinking budget. Encoded its contract in ModelSpec and tested both request paths; existing skill protocols already direct this check, no procedure change.

- 2026-11-20: The speech adapter wrapped an already formatted WAV in a second header. Added the response-format check and regression approach to `references/symptoms.md`.
2 changes: 2 additions & 0 deletions .cline/skills/nexus-model-updates/refinement-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,5 @@ Append-only record of changes made by `protocols/self-refine.md`. Newest on top.
- 2026-11-18: Added registry-anatomy guidance for googleGeneration so new models declare supported thinking levels and separate buffered/streaming foreground limits.

- 2026-11-19: Added a provider-listed model using the existing generation declaration and request-contract tests; no skill procedure change needed.

- 2026-11-20: Verified the published Gemini audio shutdown dates and exercised the saved-selection migration. The existing billing guidance covered the rejected provider probes. No procedure change.
2 changes: 2 additions & 0 deletions .cline/skills/nexus-testing/refinement-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,5 @@ Verified the installed 5.21.3 candidate in Nexus Redesign Test with matching art
- 2026-11-19: Added a provider-listed model using the existing generation declaration and request-contract tests; no skill procedure change needed.

- 2026-11-19: Confirmed Linux Obsidian1.15.1 needs command-first vault targeting for eval; documented argument order and native settings-window capture in live-loop.md.

- 2026-11-20: Verified the migration and WAV regression tests failed against the previous implementation. Ran the installed Jest binary directly after `pnpm exec` attempted to convert the npm installation. No procedure change.
1 change: 1 addition & 0 deletions .codex/skills/nexus-llm-adapters/references/symptoms.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ end quietly. Treat missing output as a swallowed failure until proven otherwise.
| Streaming works on desktop, single blob on mobile | Expected. Without a Node runtime, `requestStream()` falls back to a buffered request wrapped as a one-chunk stream. | `streaming-contract.md` |
| Settings still says “Connected” after ChatGPT rejects a Codex refresh token | The inference adapter can fail authentication without updating the persisted OAuth state. Handle only a confirmed invalid refresh token as a disconnect, persist a reconnect marker through the provider driver, and show the reconnect action in the provider modal. Do not disconnect on a temporary network or server failure. | `src/services/llm/adapters/openai-codex/OpenAICodexAdapter.ts`, `src/services/llm/providers/BuiltinProviderDrivers.ts` |
| A tool says `Request failed, status 4xx` with no explanation | A bare `requestUrl` throws on non-2xx and discards the body; Jest's mock hides this | Call `ProviderHttpClient.requestOk` with `provider` and `operation`. It keeps the provider's message and reports a missing permission as such. Pass `responseType: 'binary'` for media. |
| A speech model changes but the adapter still writes its own WAV header | The provider can return a complete RIFF/WAVE file where its previews returned raw PCM. Inspect the decoded bytes and wrap only PCM. Test with a complete WAV and require byte-for-byte preservation. | `src/services/readAloud/GoogleSpeechAdapter.ts`, `tests/unit/SpeechSynthesisService.test.ts` |

## When the symptom is not here
Debug it, fix it, then add the row. `protocols/self-refine.md` step 2 exists for
Expand Down
2 changes: 2 additions & 0 deletions .codex/skills/nexus-llm-adapters/refinement-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,5 @@ to 0). Edit `.skills/` and run `npm run sync:skills`; never edit a mirror. |
- 2026-11-10 | Gemini 4 sibling required extending exact-model request guards; existing model-update routing protocol identified every guard. No adapter skill procedure change.

- 2026-11-18: A newly listed Google family member would fall through exact model-id checks to an invalid legacy thinking budget. Encoded its contract in ModelSpec and tested both request paths; existing skill protocols already direct this check, no procedure change.

- 2026-11-20: The speech adapter wrapped an already formatted WAV in a second header. Added the response-format check and regression approach to `references/symptoms.md`.
2 changes: 2 additions & 0 deletions .codex/skills/nexus-model-updates/refinement-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,5 @@ Append-only record of changes made by `protocols/self-refine.md`. Newest on top.
- 2026-11-18: Added registry-anatomy guidance for googleGeneration so new models declare supported thinking levels and separate buffered/streaming foreground limits.

- 2026-11-19: Added a provider-listed model using the existing generation declaration and request-contract tests; no skill procedure change needed.

- 2026-11-20: Verified the published Gemini audio shutdown dates and exercised the saved-selection migration. The existing billing guidance covered the rejected provider probes. No procedure change.
2 changes: 2 additions & 0 deletions .codex/skills/nexus-testing/refinement-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,5 @@ Verified the installed 5.21.3 candidate in Nexus Redesign Test with matching art
- 2026-11-19: Added a provider-listed model using the existing generation declaration and request-contract tests; no skill procedure change needed.

- 2026-11-19: Confirmed Linux Obsidian1.15.1 needs command-first vault targeting for eval; documented argument order and native settings-window capture in live-loop.md.

- 2026-11-20: Verified the migration and WAV regression tests failed against the previous implementation. Ran the installed Jest binary directly after `pnpm exec` attempted to convert the npm installation. No procedure change.
1 change: 1 addition & 0 deletions .skills/nexus-llm-adapters/references/symptoms.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ end quietly. Treat missing output as a swallowed failure until proven otherwise.
| Streaming works on desktop, single blob on mobile | Expected. Without a Node runtime, `requestStream()` falls back to a buffered request wrapped as a one-chunk stream. | `streaming-contract.md` |
| Settings still says “Connected” after ChatGPT rejects a Codex refresh token | The inference adapter can fail authentication without updating the persisted OAuth state. Handle only a confirmed invalid refresh token as a disconnect, persist a reconnect marker through the provider driver, and show the reconnect action in the provider modal. Do not disconnect on a temporary network or server failure. | `src/services/llm/adapters/openai-codex/OpenAICodexAdapter.ts`, `src/services/llm/providers/BuiltinProviderDrivers.ts` |
| A tool says `Request failed, status 4xx` with no explanation | A bare `requestUrl` throws on non-2xx and discards the body; Jest's mock hides this | Call `ProviderHttpClient.requestOk` with `provider` and `operation`. It keeps the provider's message and reports a missing permission as such. Pass `responseType: 'binary'` for media. |
| A speech model changes but the adapter still writes its own WAV header | The provider can return a complete RIFF/WAVE file where its previews returned raw PCM. Inspect the decoded bytes and wrap only PCM. Test with a complete WAV and require byte-for-byte preservation. | `src/services/readAloud/GoogleSpeechAdapter.ts`, `tests/unit/SpeechSynthesisService.test.ts` |

## When the symptom is not here
Debug it, fix it, then add the row. `protocols/self-refine.md` step 2 exists for
Expand Down
2 changes: 2 additions & 0 deletions .skills/nexus-llm-adapters/refinement-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,5 @@ to 0). Edit `.skills/` and run `npm run sync:skills`; never edit a mirror. |
- 2026-11-10 | Gemini 4 sibling required extending exact-model request guards; existing model-update routing protocol identified every guard. No adapter skill procedure change.

- 2026-11-18: A newly listed Google family member would fall through exact model-id checks to an invalid legacy thinking budget. Encoded its contract in ModelSpec and tested both request paths; existing skill protocols already direct this check, no procedure change.

- 2026-11-20: The speech adapter wrapped an already formatted WAV in a second header. Added the response-format check and regression approach to `references/symptoms.md`.
2 changes: 2 additions & 0 deletions .skills/nexus-model-updates/refinement-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,5 @@ Append-only record of changes made by `protocols/self-refine.md`. Newest on top.
- 2026-11-18: Added registry-anatomy guidance for googleGeneration so new models declare supported thinking levels and separate buffered/streaming foreground limits.

- 2026-11-19: Added a provider-listed model using the existing generation declaration and request-contract tests; no skill procedure change needed.

- 2026-11-20: Verified the published Gemini audio shutdown dates and exercised the saved-selection migration. The existing billing guidance covered the rejected provider probes. No procedure change.
2 changes: 2 additions & 0 deletions .skills/nexus-testing/refinement-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,5 @@ Verified the installed 5.21.3 candidate in Nexus Redesign Test with matching art
- 2026-11-19: Added a provider-listed model using the existing generation declaration and request-contract tests; no skill procedure change needed.

- 2026-11-19: Confirmed Linux Obsidian1.15.1 needs command-first vault targeting for eval; documented argument order and native settings-window capture in live-loop.md.

- 2026-11-20: Verified the migration and WAV regression tests failed against the previous implementation. Ran the installed Jest binary directly after `pnpm exec` attempted to convert the npm installation. No procedure change.
14 changes: 3 additions & 11 deletions scripts/smoke-google-live.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'node:path';
import process from 'node:process';

const GOOGLE_LIVE_ENDPOINT = 'wss://generativelanguage.googleapis.com/ws/google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent';
const DEFAULT_MODEL = 'gemini-3.1-flash-live-preview';
const DEFAULT_MODEL = 'gemini-3.8-live';
const DEFAULT_PROMPT = 'Reply with exactly the single word pong.';
const DEFAULT_TIMEOUT_MS = 30000;

Expand Down Expand Up @@ -83,15 +83,7 @@ websocket.addEventListener('message', async (event) => {
if (message.setupComplete !== undefined) {
summary.setupComplete = true;
websocket.send(JSON.stringify({
clientContent: {
turns: [
{
role: 'user',
parts: [{ text: prompt }],
},
],
turnComplete: true,
},
realtimeInput: { text: prompt },
}));
return;
}
Expand Down Expand Up @@ -278,4 +270,4 @@ function describeMessagePayload(data) {
}

return typeof data;
}
}
9 changes: 5 additions & 4 deletions src/services/llm/types/RetiredMediaModels.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Image and video model ids that providers have shut down or scheduled for
* Media model ids that providers have shut down or scheduled for
* shutdown, each with the successor the provider documents.
*
* The catalogs no longer offer these ids, but saved settings, per-conversation
Expand Down Expand Up @@ -72,15 +72,16 @@ const RETIRED_VIDEO_MODELS: Readonly<Partial<Record<VideoProvider, Readonly<Reco
// predecessor's voices, so a saved voice keeps working.
const RETIRED_SPEECH_MODELS: Readonly<Record<string, Readonly<Record<string, Omit<RetiredModel, 'id'>>>>> = {
google: {
'gemini-3.1-flash-tts-preview': { replacement: 'gemini-3.8-flash-tts', shutdown: '2026-11-17' },
'gemini-2.5-flash-preview-tts': { replacement: 'gemini-3.8-flash-tts', shutdown: '2026-11-17' },
'gemini-2.5-pro-preview-tts': { replacement: 'gemini-3.8-flash-tts', shutdown: '2026-11-17' },
'gemini-3.1-flash-tts-preview': { replacement: 'gemini-3.8-flash-tts', shutdown: '2026-12-18' },
'gemini-2.5-flash-preview-tts': { replacement: 'gemini-3.8-flash-tts', shutdown: '2026-12-18' },
'gemini-2.5-pro-preview-tts': { replacement: 'gemini-3.8-flash-tts', shutdown: '2026-12-18' },
},
};

const RETIRED_REALTIME_MODELS: Readonly<Record<string, Readonly<Record<string, Omit<RetiredModel, 'id'>>>>> = {
google: {
'gemini-3.1-flash-live-preview': { replacement: 'gemini-3.8-live', shutdown: '2026-11-17' },
'gemini-2.5-flash-native-audio-preview-12-2025': { replacement: 'gemini-3.8-live', shutdown: '2027-03-31' },
},
openai: {
'gpt-realtime-mini': { replacement: 'gpt-realtime-2.1-mini', shutdown: '2027-01-20' },
Expand Down
12 changes: 10 additions & 2 deletions src/services/readAloud/GoogleSpeechAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ export class GoogleSpeechAdapter implements SpeechAdapter {
});

const data = getInlineAudioData(response.json as GoogleGenerateContentResponse);
const pcmAudio = decodeBase64(data);
const wavAudio = wrapPcmAsWav(pcmAudio);
const audio = decodeBase64(data);
// Gemini 3.8 TTS returns WAV by default. Older responses can contain raw PCM.
const wavAudio = hasWavHeader(audio) ? audio : wrapPcmAsWav(audio);

return {
provider: this.provider,
Expand All @@ -89,6 +90,13 @@ export class GoogleSpeechAdapter implements SpeechAdapter {
}
}

function hasWavHeader(audio: ArrayBuffer): boolean {
if (audio.byteLength < 12) return false;
const header = new Uint8Array(audio, 0, 12);
return String.fromCharCode(...header.subarray(0, 4)) === 'RIFF'
&& String.fromCharCode(...header.subarray(8, 12)) === 'WAVE';
}

function getInlineAudioData(response: GoogleGenerateContentResponse): string {
const data = response.candidates?.[0]?.content?.parts?.[0]?.inlineData?.data;
if (typeof data !== 'string' || data.length === 0) {
Expand Down
11 changes: 5 additions & 6 deletions src/services/readAloud/SpeechSynthesisService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,10 @@ export class SpeechSynthesisService {
}

const settingsDefault = this.llmSettings?.defaultSpeechModel;
const defaultModel = settingsDefault?.provider === provider ? settingsDefault.model : undefined;
const requested = request.model || defaultModel || providerAvailability.models?.[0]?.id;
const model = getRetiredSpeechModel(provider, requested)?.replacement ?? requested;
const savedModel = settingsDefault?.provider === provider ? settingsDefault.model : undefined;
const defaultModel = getRetiredSpeechModel(provider, savedModel)?.replacement ?? savedModel;
const requestedModel = getRetiredSpeechModel(provider, request.model)?.replacement ?? request.model;
const model = requestedModel || defaultModel || providerAvailability.models?.[0]?.id;
if (!model) {
return {
provider,
Expand All @@ -130,9 +131,7 @@ export class SpeechSynthesisService {
}

const modelDefaultVoice = getSpeechModel(provider, model)?.defaultVoice;
const settingsDefaultVoice = settingsDefault?.provider === provider && settingsDefault.model === model
? settingsDefault.voice
: undefined;
const settingsDefaultVoice = defaultModel === model ? settingsDefault?.voice : undefined;

return {
provider,
Expand Down
5 changes: 1 addition & 4 deletions tests/debug/realtime-voice-google-live-smoke.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,7 @@ describeLive('Google realtime voice live smoke', () => {
// session's own outbound path. Google answers it with audio + transcript
// exactly as it would a spoken turn.
(session as unknown as SessionWithInternals).sendMessage({
clientContent: {
turns: [{ role: 'user', parts: [{ text: 'Say hello and tell me which model you are, in one sentence.' }] }],
turnComplete: true,
},
realtimeInput: { text: 'Say hello and tell me which model you are, in one sentence.' },
});

await Promise.race([
Expand Down
Loading
Loading