diff --git a/src/tui.ts b/src/tui.ts index 67540d0..94491ff 100644 --- a/src/tui.ts +++ b/src/tui.ts @@ -19,6 +19,8 @@ function createModelRouter(config: Config): ModelRouter { const defaultClient = new AnthropicClient({ model: models.default.model, + apiKey: models.default.api_key, + authToken: models.default.auth_token, }); let fastClient; @@ -26,11 +28,19 @@ function createModelRouter(config: Config): ModelRouter { let localClient; if (models.fast) { - fastClient = new AnthropicClient({ model: models.fast.model }); + fastClient = new AnthropicClient({ + model: models.fast.model, + apiKey: models.fast.api_key, + authToken: models.fast.auth_token, + }); } if (models.complex) { - complexClient = new AnthropicClient({ model: models.complex.model }); + complexClient = new AnthropicClient({ + model: models.complex.model, + apiKey: models.complex.api_key, + authToken: models.complex.auth_token, + }); } if (models.local) { @@ -100,15 +110,19 @@ async function main() { await startFullscreenTui({ session, modelClient: modelRouter, + modelRouter, systemPrompt: SYSTEM_PROMPT, model: config.models.default.model, onExit: cleanup, }); } else { // Start minimal readline UI + let switchingToFullscreen = false; + const tui = new MinimalTui({ session, modelClient: modelRouter, + modelRouter, systemPrompt: SYSTEM_PROMPT, onTransfer: (target) => { if (target === 'telegram') { @@ -119,25 +133,26 @@ async function main() { console.log(`Unknown transfer target: ${target}\n`); } }, - onFullscreen: async () => { - tui.stop(); - console.clear(); - await startFullscreenTui({ - session, - modelClient: modelRouter, - systemPrompt: SYSTEM_PROMPT, - model: config.models.default.model, - onExit: () => { - // Return to minimal mode would require re-init - // For now, just exit - cleanup(); - process.exit(0); - }, - }); + onFullscreen: () => { + switchingToFullscreen = true; + tui.stop(true); // Preserve stdin for fullscreen mode }, }); await tui.start(); + + if (switchingToFullscreen) { + console.clear(); + await startFullscreenTui({ + session, + modelClient: modelRouter, + modelRouter, + systemPrompt: SYSTEM_PROMPT, + model: config.models.default.model, + onExit: cleanup, + }); + return; + } } cleanup();