From 014736bc1d9e117c6a60cef7de48f8c79a93afd6 Mon Sep 17 00:00:00 2001 From: Shirone Date: Sun, 25 Jan 2026 19:49:41 +0100 Subject: [PATCH 1/3] fix: Check Claude Code CLI auth before showing warning The startup warning "No Claude authentication configured" was shown even when users have Claude Code CLI installed and authenticated with a subscription. The Claude Agent SDK can reuse CLI authentication, so this was a false positive. Now checks for Claude Code CLI authentication indicators before showing the warning: - Recent CLI activity (stats cache) - CLI setup indicators (settings + project sessions) - OAuth credentials file Also updated the warning message to list all authentication options. Co-Authored-By: Claude Opus 4.5 --- apps/server/src/index.ts | 48 +++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/apps/server/src/index.ts b/apps/server/src/index.ts index ab3d60f5..347f6b57 100644 --- a/apps/server/src/index.ts +++ b/apps/server/src/index.ts @@ -16,7 +16,7 @@ import { createServer } from 'http'; import dotenv from 'dotenv'; import { createEventEmitter, type EventEmitter } from './lib/events.js'; -import { initAllowedPaths } from '@automaker/platform'; +import { initAllowedPaths, getClaudeAuthIndicators } from '@automaker/platform'; import { createLogger, setLogLevel, LogLevel } from '@automaker/utils'; const logger = createLogger('Server'); @@ -117,15 +117,42 @@ export function isRequestLoggingEnabled(): boolean { // Width for log box content (excluding borders) const BOX_CONTENT_WIDTH = 67; -// Check for required environment variables -const hasAnthropicKey = !!process.env.ANTHROPIC_API_KEY; +// Check for Claude authentication (async - runs in background) +// The Claude Agent SDK can use either ANTHROPIC_API_KEY or Claude Code CLI authentication +(async () => { + const hasAnthropicKey = !!process.env.ANTHROPIC_API_KEY; -if (!hasAnthropicKey) { + if (hasAnthropicKey) { + logger.info('✓ ANTHROPIC_API_KEY detected'); + return; + } + + // Check for Claude Code CLI authentication + try { + const indicators = await getClaudeAuthIndicators(); + const hasCliAuth = + indicators.hasStatsCacheWithActivity || + (indicators.hasSettingsFile && indicators.hasProjectsSessions) || + (indicators.hasCredentialsFile && indicators.credentials?.hasOAuthToken); + + if (hasCliAuth) { + logger.info('✓ Claude Code CLI authentication detected'); + return; + } + } catch { + // Ignore errors checking CLI auth - will fall through to warning + } + + // No authentication found - show warning const wHeader = '⚠️ WARNING: No Claude authentication configured'.padEnd(BOX_CONTENT_WIDTH); const w1 = 'The Claude Agent SDK requires authentication to function.'.padEnd(BOX_CONTENT_WIDTH); - const w2 = 'Set your Anthropic API key:'.padEnd(BOX_CONTENT_WIDTH); - const w3 = ' export ANTHROPIC_API_KEY="sk-ant-..."'.padEnd(BOX_CONTENT_WIDTH); - const w4 = 'Or use the setup wizard in Settings to configure authentication.'.padEnd( + const w2 = 'Options:'.padEnd(BOX_CONTENT_WIDTH); + const w3 = '1. Install Claude Code CLI and authenticate with subscription'.padEnd( + BOX_CONTENT_WIDTH + ); + const w4 = '2. Set your Anthropic API key:'.padEnd(BOX_CONTENT_WIDTH); + const w5 = ' export ANTHROPIC_API_KEY="sk-ant-..."'.padEnd(BOX_CONTENT_WIDTH); + const w6 = '3. Use the setup wizard in Settings to configure authentication.'.padEnd( BOX_CONTENT_WIDTH ); @@ -138,14 +165,13 @@ if (!hasAnthropicKey) { ║ ║ ║ ${w2}║ ║ ${w3}║ -║ ║ ║ ${w4}║ +║ ${w5}║ +║ ${w6}║ ║ ║ ╚═════════════════════════════════════════════════════════════════════╝ `); -} else { - logger.info('✓ ANTHROPIC_API_KEY detected'); -} +})(); // Initialize security initAllowedPaths(); From c9c406dd21a6357f7679fc500299f120694ffeb4 Mon Sep 17 00:00:00 2001 From: Shirone Date: Sun, 25 Jan 2026 19:53:19 +0100 Subject: [PATCH 2/3] fix: Improve error handling for Claude Code CLI authentication check Updated the error handling in the Claude Code CLI authentication check to log the specific error encountered. This enhancement provides better visibility into issues during the authentication process, ensuring users are informed of any problems that arise. --- apps/server/src/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/server/src/index.ts b/apps/server/src/index.ts index 347f6b57..12da84a9 100644 --- a/apps/server/src/index.ts +++ b/apps/server/src/index.ts @@ -139,8 +139,9 @@ const BOX_CONTENT_WIDTH = 67; logger.info('✓ Claude Code CLI authentication detected'); return; } - } catch { + } catch (error) { // Ignore errors checking CLI auth - will fall through to warning + logger.warn('Error checking for Claude Code CLI authentication:', error); } // No authentication found - show warning From 45706990dfb36f278238c9f35b2b5a45db0ba175 Mon Sep 17 00:00:00 2001 From: Shirone Date: Sun, 25 Jan 2026 20:04:16 +0100 Subject: [PATCH 3/3] fix: Also check hasApiKey for CLI authentication Address CodeRabbit review comment - API keys stored in CLI credentials file should also be detected as valid authentication. Co-Authored-By: Claude Opus 4.5 --- apps/server/src/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/server/src/index.ts b/apps/server/src/index.ts index 12da84a9..4bd496bc 100644 --- a/apps/server/src/index.ts +++ b/apps/server/src/index.ts @@ -133,7 +133,8 @@ const BOX_CONTENT_WIDTH = 67; const hasCliAuth = indicators.hasStatsCacheWithActivity || (indicators.hasSettingsFile && indicators.hasProjectsSessions) || - (indicators.hasCredentialsFile && indicators.credentials?.hasOAuthToken); + (indicators.hasCredentialsFile && + (indicators.credentials?.hasOAuthToken || indicators.credentials?.hasApiKey)); if (hasCliAuth) { logger.info('✓ Claude Code CLI authentication detected');