# CHANGELOG ### [2026-08-31] - OpenRouter Exclusive Engine Migration & Unified API Routing **Type:** Migration | Architecture | Feature | Performance **Context:** Completely eliminated direct Google API key dependencies in favor of exclusive OpenRouter integration (`https://openrouter.ai/api/v1`) across frontend roleplay streaming, speech synthesis/transcription, clinical supervision, scenario generation, and backend Azure Functions. **Resolution:** - **OpenRouter Exclusive Architecture:** Removed all `@google/genai` client libraries and direct Google Gemini API key requirements. All model interactions (including `google/gemini-2.5-flash`, `google/gemini-2.0-flash-001`, `anthropic/claude-3.5-haiku`, `meta-llama/llama-3.3-70b-instruct`) route exclusively through OpenRouter with standard Bearer authorization. - **Frontend Streaming SSE & TTS:** Upgraded `services/openRouterService.ts` to support Server-Sent Events (SSE) token streaming, structured turn evaluation in JSON mode, and high-fidelity speech synthesis. - **Live Voice Processing:** Refactored `hooks/useLiveSession.ts` to use browser speech recognition + WebAudio frequency analysis for microphone input, coupled with OpenRouter speech synthesis and turn analysis. - **Backend Azure Functions Alignment:** Refactored `api/ChatFunction.cs`, `api/AnalysisFunction.cs`, and `api/ScenarioFunction.cs` to utilize `HttpClientFactory` and `OPENROUTER_API_KEY`, removing the `Google.GenAI` NuGet package. - **Settings & UI Redesign:** Replaced provider toggles in `components/SettingsModal.tsx` with dedicated OpenRouter API Key input and model selector. - **Bundle Shrinkage:** Reduced total precache build size from 703 kB to 439 kB by removing heavy GenAI SDK dependencies. **Files Changed:** - `services/openRouterService.ts` - `services/apiConfig.ts` - `hooks/useLiveSession.ts` - `components/ChatSession.tsx` - `components/VoiceSession.tsx` - `components/ScenarioGenerator.tsx` - `components/SettingsModal.tsx` - `constants.ts` - `types.ts` - `App.tsx` - `index.html` - `vite.config.ts` - `api/api.csproj` - `api/Program.cs` - `api/ChatFunction.cs` - `api/AnalysisFunction.cs` - `api/ScenarioFunction.cs` - `AGENTS.md` - `GEMINI.md` - `README.md` - `CHANGELOG.md` **Files Changed:** - `hooks/useLiveSession.ts` - `services/apiConfig.ts` - `services/openRouterService.ts` - `services/sessionStorage.ts` - `components/SessionReport.tsx` - `components/SettingsModal.tsx` - `components/ChatSession.tsx` - `components/VoiceSession.tsx` - `components/ScenarioGenerator.tsx` - `types.ts` - `App.tsx` - `vite.config.ts` - `sw.ts` - `CHANGELOG.md` ### [2026-08-30] - Architectural Assessment, Type Alignment & Agentic Tooling **Type:** Refactor | Bug Fix | Feature | Config **Context:** Comprehensive full-codebase architectural evaluation of Cognitive Clarity (`clarity-helper`), fixing TypeScript / .NET compilation blockers, enriching CBT domain coverage, and establishing workspace agent instructions, custom skills, and scenario test helpers. **Resolution:** - Fixed TypeScript 5.8 / React 19 typing discrepancy on `BadgeProps` in `components/ui/badge.tsx`. - Upgraded C# Azure Functions in `api/` to `Google.GenAI` 1.20+ SDK, resolving all namespace ambiguities and schema definitions across `ChatFunction.cs`, `AnalysisFunction.cs`, and `ScenarioFunction.cs`. - Enriched `CBT_GLOSSARY` in `constants.ts` with missing definitions for `Labeling` and `Overgeneralization`. - Added explicit `INTERNAL CBT LOGIC:` branching rules across built-in scenarios `s1`, `s3`, and `s4`. - Created comprehensive workspace guidelines and rules in `AGENTS.md` and `GEMINI.md`. - Created custom agent skills in `.agents/skills/`: - `cbt-scenario-design` - `webaudio-gemini-live` - `cbt-clinical-evaluation` - `azure-functions-genai` - Authored developer CLI helpers in `scripts/`: - `scripts/validate-scenarios.ts` (Validates 14 built-in scenarios against clinical schema) - `scripts/simulate-cbt-session.ts` (Headless multi-turn roleplay & clinical scoring simulator) - Updated `package.json` with `validate:scenarios` and `simulate:session` npm script targets and installed `tsx`. - Elevated `README.md` to publication-grade documentation with complete architecture diagrams, endpoint matrices, and developer guide. **Files Changed:** - `components/ui/badge.tsx` - `constants.ts` - `package.json` - `package-lock.json` - `api/api.csproj` - `api/ChatFunction.cs` - `api/AnalysisFunction.cs` - `api/ScenarioFunction.cs` - `scripts/validate-scenarios.ts` - `scripts/simulate-cbt-session.ts` - `.agents/skills/cbt-scenario-design/SKILL.md` - `.agents/skills/webaudio-gemini-live/SKILL.md` - `.agents/skills/cbt-clinical-evaluation/SKILL.md` - `.agents/skills/azure-functions-genai/SKILL.md` - `AGENTS.md` - `GEMINI.md` - `README.md` - `CHANGELOG.md`